CentOS 7.6 uses mysql-8.0.31-1.el7.x86_64.rpm-bundle.tar to install Mysql 8.0

https://downloads.mysql.com/archives/community/ is the official website of the community version. You can choose the version to download.

cat /etc/redhat-release can see that the system version is CentOS Linux release 7.6.1810 (Core), uname -r can see The version is 3.10.0-957.el7.x86_64.

yum remove -y mysql-libsUninstall some components installed by default mariadb.

wget https://cdn.mysql.com/archives/mysql-8.0/mysql-8.0.31-1.el7.x86_64.rpm-bundle.tarDownload and install components.

mkdir /mysql8031Create a special storage directory after tar decompression, tar -xf mysql-8.0.31-1.el7.x86_64.rpm-bundle.tar -C /mysql8031 Unzip to a specific directory, cd /mysql8031 switches the working directory, which is equivalent to entering this directory, ls -l /mysql8031 can take a look at the contents of the directory after decompression.

The installation sequence is: common => client-plugins => libs => client => icu-data-files => server. The installation commands are as follows:
rpm -ivh mysql-community-common-8.0.31-1.el7.x86_64.rpm

rpm -ivh mysql-community-client-plugins-8.0.31-1.el7.x86_64.rpm

rpm -ivh mysql-community-libs-8.0.31-1.el7.x86_64.rpm, found that /sbin/ldconfig: /lib64/libstdc + + .so.6 is not a symbolic link prompt, the reason I mentioned here is because I did not specify the correct URL of the link library when I used the source code to upgrade the gcc version to 12.2.0.

cat << EOF >> /etc/ld.so.conf adds /usr/local/gcc-12.2/lib64/ to /etc/ld. inside so.conf.

ldconfig loaded the configuration file and found that ldconfig: /lib64/libstdc + + .so.6 is not a symbolic link was still reported.

rm -rf /lib64/libstdc + + .so.6Delete the file.

ln -s /usr/local/gcc-12.2/lib/libstdc + + .so.6 /lib64/libstdc + + .so.6Create a soft link.

ldconfigReloads the configuration file.

rpm -e mysql-community-libs-8.0.31-1.el7.x86_64Uninstall.

rpm -ivh mysql-community-libs-8.0.31-1.el7.x86_64.rpmReinstall.

rpm -ivh mysql-community-client-8.0.31-1.el7.x86_64.rpm

rpm -ivh mysql-community-icu-data-files-8.0.31-1.el7.x86_64.rpm

rpm -ivh mysql-community-server-8.0.31-1.el7.x86_64.rpm

systemctl start mysqldStart the MySQL server.
systemctl status mysqld sees that the MySQL server status is active (running).

cat /var/log/mysqld.log | grep passwordView the randomly generated password, my random password is jIMsl8Ti(wj(.

Use mysql -u root -p to connect to the client, and enter the password jIMsl8Ti(wj( to enter. Note that the password is not visible during the input process.

The command format used to change the password is ALTER USER 'username'@'ip address' IDENTIFIED BY 'password'; For example, the command I use is ALTER USER ' root'@'localhost' IDENTIFIED BY 'ILoveyou#3';This command means to change the local root user password to ILoveyou#3 .

show databases;You can see all databases.

When using grant all privileges on *.* to 'root'@'%' identified by 'ILoveyou#3' with grant option; the error is reported as follows:

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'identified by 'ILoveyou#3' with grant option\ ' at line 1

Refer to the blog “MySQL8.0:grant all privileges on . to error reporting”

CREATE USER 'gooduser'@'%' IDENTIFIED BY 'Good#1103';Create user gooduser with password Good#1103. grant all privileges on *.* to 'gooduser'@'%';Enable any IP to connect to MySQL. Use flush privileges; to refresh, otherwise the permissions will not take effect.

quit can exit the MySQL command line.

mysql -u gooduser -p, then enter the password Good#1103 to test and log in successfully.