Environment: Linux Centos8 4.18.0-80.el8.x86_64, Mysql8.0.18

1. Download the RPM package from the Mysql website

2. Check whether it has been installed

rpm -qa | grep -i mysql
Copy the code

3. Uninstall the previous installation

rpm -e--nodeps software name // Forcible deletion, also forcible deletion of related dependent filesCopy the code

Mysql > install mysql-client

RPM -ivh RPM package * Install mysql-community-common-8.0.18 * Install mysql-community-libs-8.0.18 * Install mysql-community-client-8.0.18Copy the code

Mysql > install mysql-server

6. Check whether the installation is successful

Have the following view: * ps - ef | grep mysql * cat/etc/group | grep mysql * cat/etc/password | grep mysql * mysqladmin -- version...Copy the code

7. Initialize mysql

Mysqld --initialize // create data file directory and mysql system database generate random root passwordCopy the code

8. Start the mysql service

systemctl start mysqld
Copy the code

Startup failed because the /var/lib/mysql directory did not have enough permissionsCopy the code

Mysql /var/lib/mysql

chown -R mysql:mysql /var/lib/mysql/
Copy the code

10. Start the mysql service

Systemctl start mysqld / / start ps - ef | grep mysql / / see the mysql serviceCopy the code

11. Initialize the randomly generated root password

cat /var/log/mysqld.log | grep password
Copy the code

12. Security Settings

mysql_secure_installation
Copy the code

Mysql > log in to mysql

Mysql -uroot -p // Random password loginCopy the code

Mysql8.0+ Mysql8.0+ Mysql8.0+ Mysql8.0

Mysql > select * from user root; update userset authentication_string=' ' where user='root'; Note: Mysql5.7+ password field has been changed to authentication_stringCopy the code

Reset to the new password alter user'root'@'localhost' identified by 'newpassword'; Note: Before Mysql8.0: update userset password=password('root') where user='root';
Copy the code

15. Log out and use the new password to log in to mysql again

mysql -uroot -proot
Copy the code

16, How do I stop, restart, and view mysql services

Systemctl stop mysqld // Stop the service systemctl restart mysqld // Restart the service systemctl status mysqld // View the serviceCopy the code

Mysql installation directory files

/usr/bin// related commandsCopy the code

/usr/share/mysql // Configuration file directoryCopy the code

/var/lib/mysql./ Directory for storing database filesCopy the code

/etc/my.cnf //mysql startup configuration fileCopy the code

In the 18th and postscript

Ini // Configuration file for Windows my. CNF // Configuration file for Linux mysqld // is the background daemon process, that is, mysql daemon mysql // is the client command lineCopy the code