Table of contents
- 1. Xftp7 download
- 2. Download the MySQL8 installation package
- 3. Upload the MySQL8 installation package to the server
- 4. Unzip the mysql8 installation package
- 5. Installation of rpm package
- 6. Install the following files in order
- 7. Initialize and authorize MySQL
- 8. View the database initial password
- 9. Start the MySQL service
- 10. Log in to MySQL using the initial password
- About uninstalling MySQL
1. Xftp7 download
I will not demonstrate the downloading of Xftp7. After downloading, it will look like this:
We need to use Xftp7 to upload the MySQL8 installation package to the server.
2. Download the MySQL8 installation package
There are two ways to install the MySQL8 installation package:
Official website : https://dev.mysql.com/downloads/mysql
Site C : https://download.csdn.net/download/zp8126/20694042
After the download is successful, it will look like this:
3. Upload the MySQL8 installation package to the server
We need to use it Xftp7
to upload the MySQL8 installation package to the server.
First open Xshell:
Then upload the MySQL8 installation package we downloaded to the server, and then wait for the transfer to complete:
This is considered a successful transfer.
Here we installed the MySQL8 installation package into the opt directory, and then created a new mysql8.0.26 folder in the opt directory, that is, moved the MySQL8 installation package to the mysql8.0.26 folder. Please see:
4. Unzip the mysql8 installation package
Since we moved the mysql8 installation package to the mysql8.0.26 folder, we first enter the mysql8.0.26 folder and then unzip it in this directory.
Enter the command to decompress :tar -xvf mysql-8.0.26-1.el7.x86_64.rpm-bundle.tar
The decompression results are as follows:
5. Installation of rpm package
First go to this address to download: https://developer.aliyun.com/packageSearch?word=telnet
That is:
The download process will not be demonstrated here.
6. Install the following files in order
Put important things first :
- Note that the installed file name must be consistent with the file name extracted above.
- Be careful to choose forced installation
- Install the following commands in order:
Command 1: rpm -ivh mysql-community-common-8.0.26-1.el7.x86_64.rpm
Command 2: rpm -ivh mysql-community-libs-8.0.26-1.el7.x86_64.rpm --nodeps --force
Command 3: rpm -ivh mysql-community-client-8.0.26-1.el7.x86_64.rpm --nodeps --force
Command 4:rpm -ivh mysql-community-server-8.0.26-1.el7.x86_64.rpm --nodeps --force
Okay, after following the above 4 commands, we check whether the following is successful and
enter the command:rpm -qa | grep mysql
7. Initialize and authorize MySQL
Enter command 1:
mysqld --initialize;
After entering command 1, if the following error is displayed, you need to enter the command:yum install -y libaio
Then execute command 1 again, please see:
Enter command 2:
chown mysql:mysql /var/lib/mysql -R;
8. View the database initial password
input the command:cat /var/log/mysqld.log | grep password
9. Start the MySQL service
Enter command 1:
systemctl start mysqld.service;
Enter command 2:
systemctl enable mysqld;
10. Log in to MySQL using the initial password
Enter the command: mysql -u root -p
, then enter your password to log in!
Now we enter the command:
show databases;
Check which databases there are:
an error will be reported at this time, because we have not reset the password.
Enter the command to reset the password :
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '新密码';
the modification is successful here.
At this point we are executing the command to see which databases are currently available:
show database;
At this point, the installation of MySQL8 is officially completed.
About uninstalling MySQL
- Stop the MySQL service:
systemctl stop mysqld
- Query the MySQL installation file:
rmp -qa | grep -i mysql
- Uninstall all MySQL installation packages queried above:
rpm -e --nodeps mysql-x.x.x.x
- Delete the MySQL data storage directory:
rm -rf /var/lib/mysql/
- Delete MySQL configuration file backup:
rm -rf /etc/my.cnf.rpmsave