In CentOS, MariaDB is installed by default, which is a branch of MySQL. However, MySQL should be installed in the system for the sake of need, and MariaDB can be directly overridden after the installation.
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm #Download the yum repository for installation yum -y install mysql57-community-release-el7-10. noarch.rpm #Yum install MySQL RPM package Yum - y install MySQL community server
Mysql database settings
systemctl start mysqld.service #Start MySQL systemctl status mysqld.service #View MySQL running status
Modify database initial password
If you do not know the password before entering the database, you can find the password in the log file by the following command
grep "password" /var/log/ mysqld.log #In mysqld.log The line in the file that filters the string "password."
MySQL - uroot - P ා log in to MySQL with root account and password
Enter the initial password. Nothing can be done at this time, because MySQL must change the password by default to operate the database
mysql>ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';
Or to grant access to other database users:
mysql>GRANT ALL PRIVILEGES ON *.* TO 'twonian'@'%' IDENTIFIED BY 'plato001' WITH GRANT OPTION; mysql>FLUSH PRIVILEGES;
If the report is wrong
Your password does not satisfy the current policy requirements
This is the temporary password used during MySQL initialization. When modifying the user-defined password, because the user-defined password is relatively simple, there is a problem that does not conform to the password policy.
To view the initial password policy of MySQL:
SHOW VARIABLES LIKE 'validate_password%';
The solution is to change the password policy:
mysql> set global validate_password_policy=0; mysql> set global validate_password_length=6;