1. Check whether Mysql has been installed
rpm -qa | grep mysql
If you find something, you can use the following command to delete it
rpm -e filename
Two, mysql package
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
3. Install the mysql package
yum -y install mysql57-community-release-el7-10.noarch.rpm
4. Install mysql
yum -y install mysql-community-server
5. If you execute "yum -y install mysql-community-server"
"Error: GPG check FAILED" appears during the command, you can add "--nogpgcheck" after this command, that is, "yum -y install mysql-community-server --nogpgcheck"
6. Start the mysql service
systemctl start mysqld.service
7. View the running status of mysql
Service mysqld status
sees a green, which means the startup is successful.
Eight, view the initial password
If grep ' password ' /var/log/mysqld.log cannot be seen, it means that there is no password.
Nine, enter the database
After entering the command mysql -u root -p , click Enter, and you will be asked to enter the password, and then enter the initial password just now. If there is no password, just press Enter.
10. Modify the MySql configuration file my.cnf and add skip-grant-tables
find / -name my.cnf
Eleven, remember to close the mysql service before modifying the file
service mysqld stop
12. Enter the file through the vi or vim command
Thirteen, add skip-grant-tables, add skip-grant-tables, so that mysql can log in without password.
14. Restart the service
service mysqld start
connect to MySql again and reset the password
You can enter with any password
mysql -u root -p
Fifteen, through show databases; pay attention to the number; to view the database, and then use mysql; to enter the database
Sixteen, reset the password to
update user set authentication_string=password('root') where user='root';
17. Modify the configuration file my.cnf, delete skip-grant-tables, restart, and log in again
remove skip-grant-tables
Delete this command and save and exit
18. Restart the service
service mysqld start
19. Enter the MySQL database according to the instructions
mysql -uroot -p