Centos7 installation mysql8.0 operation steps (yum installation method)

The following operations were successfully performed on Centos7.5.

1. Uninstall MariaDB first

rpm -qa | grep -i mariadb (check if there is mariadb)

rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64 (uninstall directly without checking dependencies)

2. Check whether there is mysql residue (if there is, it is best to uninstall it, and reinstall it below)

rpm -qa | grep mysql

3. Download the mysql library (need to connect to the Internet)

wget https://repo.mysql.com//mysql80-community-release-el7-3.noarch.rpm

Fourth, install the mysql library

yum -y install mysql80-community-release-el7-3.noarch.rpm

5. Reacquire the GPG of mysql (if not executed, the next step of yum installation will report an error)

rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022

6. Install mysql (mysql8.0 is installed by default)

yum -y install mysql-community-server

7. Start the mysql service

systemctl start mysqld

8. Check the running status of mysql (non-essential operation)

systemctl status mysqld (if not running, execute systemctl start mysqld)

 
 

 9. View the default password (non-essential operation)

cat /var/log/mysqld.log | grep password

 
 

At this point, mysql8.0 has been installed. In order to use mysql more conveniently, the following is the operation of changing the password and enabling remote access.

10. Set mysql password-free login to modify the password

vim /etc/my.cnf (edit file)

Add skip-grant-tables

wq! save and exit

systemctl restart mysqld (restart the service to make the configuration take effect)

11. Log in to mysql (password free, press any key to log in)

mysql -uroot -p

12. Modify the mysql default password

use mysql; (switch to mysql library)

SHOW variables LIKE 'validate_password%'; (non-essential operation, query table)

 
 

set global validate_password.policy=0; (lower the password limit)

set global validate_password.length=4; (lower the password limit)

flush privileges; (refresh to take effect)

ALTER USER 'root'@'localhost' IDENTIFIED BY '123456'; (set password 123456)

flush privileges; (refresh to take effect)

Thirteen, set up root account remote access

select user, host, plugin from user; (query table)

 update user set host = '%' where user = 'root'; (set root to access any address)

 
 

update user set plugin = 'mysql_native_password' where user = 'root'; (not necessary, because mysql8.0 has been changed to a new plugin caching_sha2_password, an error will be reported when logging in with navicat12, you can execute this command to change back to the old plugin mysql_native_password, Or upgrade navicat to version 16, version 16 already supports caching_sha2_password)

flush privileges; (refresh to take effect)

exit (exit mysql)

14. Cancel password-free login

vim /etc/my.cnf (edit file)

remove skip-grant-tables

wq! save and exit

systemctl restart mysqld (restart the service to make the configuration take effect)

15. Open the default port of 3306 database (remote login needs to be opened)

systemctl status firewalld (check whether the firewall is enabled, if not, execute systemctl start firewalld)

firewall-cmd --permanent --add-port=3306/tcp (permanently add port 3306)

firewall-cmd --reload (refresh to take effect)

firewall-cmd --list-ports (non-essential operation, check whether the port is enabled)

Sixteen, verify login

Log in to mysql locally successfully

 navicat16 remote login to mysql successfully

Guess you like

Origin blog.csdn.net/v781423070/article/details/128331682