Detailed tutorial on installing MySQL8 in Centos7 environment

1. Xftp7 download

I will not demonstrate the downloading of Xftp7. After downloading, it will look like this:
Insert image description here
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:
Insert image description here

3. Upload the MySQL8 installation package to the server

We need to use it Xftp7to upload the MySQL8 installation package to the server.

First open Xshell:
Insert image description here
Insert image description here

Then upload the MySQL8 installation package we downloaded to the server, and then wait for the transfer to complete:
Insert image description here

Insert image description here

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:
Insert image description here

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:
Insert image description here
Insert image description here

5. Installation of rpm package

First go to this address to download: https://developer.aliyun.com/packageSearch?word=telnet
That is:Insert image description here
Insert image description here

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
Insert image description here
Command 2: rpm -ivh mysql-community-libs-8.0.26-1.el7.x86_64.rpm --nodeps --force
Insert image description here
Command 3: rpm -ivh mysql-community-client-8.0.26-1.el7.x86_64.rpm --nodeps --force
Insert image description here
Command 4:rpm -ivh mysql-community-server-8.0.26-1.el7.x86_64.rpm --nodeps --force
Insert image description here

Okay, after following the above 4 commands, we check whether the following is successful and
enter the command:rpm -qa | grep mysql
Insert image description here

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
Insert image description here
Insert image description here
Then execute command 1 again, please see:
Insert image description here

Enter command 2:chown mysql:mysql /var/lib/mysql -R;
Insert image description here

8. View the database initial password

input the command:cat /var/log/mysqld.log | grep password
Insert image description here

9. Start the MySQL service

Enter command 1:systemctl start mysqld.service;
Insert image description here

Enter command 2:systemctl enable mysqld;
Insert image description here

10. Log in to MySQL using the initial password

Enter the command: mysql -u root -p, then enter your password to log in!
Insert image description here

Now we enter the command: show databases;Check which databases there are:
Insert image description here
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 '新密码';
Insert image description here
the modification is successful here.

At this point we are executing the command to see which databases are currently available:show database;
Insert image description here

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

Guess you like

Origin blog.csdn.net/m0_74352571/article/details/133457009