Method 1:
1. Stop the MySQL service
# Kill ' Cat/var/run/mysqld/mysqld.pid '
Or
# Pkill Mysqld
2. Create a text file for a password assignment statement
# VI Mysql-init
ALTER USER ' root ' @ ' localhost ' identifiedby ' mynewpass!6 ';
Resets the password before loading the authorization table.
3. Start the MySQL service using the-init-file option
# mysqld--init-file=mysql-init--user=mysql &
4. Delete the text file and connect to MySQL using the new password
# rm-f Mysql-init
# mysql-uroot-p ' mynewpass!6 '
5. Stop the MySQL service and start normally
# Kill ' Cat/var/run/mysqld/mysqld.pid '
# Systemctl Start mysqld
Method 2:
1. Stop the MySQL service
# Kill ' Cat/var/run/mysqld/mysqld.pid '
# Pkill Mysqld
2. Start the MySQL service using the--skip-grant-tables--skip-networking option
# mysqld--skip-grant-tables--skip-networking--user=mysql
--skip-grant-tables: Skip Authorization Form authentication
--skip-networking: With the Skip authorization table option, all people can log in without a password, which is very insecure, this option does not listen to the network and prevents malicious logons.
3. No password connection to MySQL
# MySQL
4. Reset Password
mysql> FLUSH privileges;
Mysql> ALTER USER ' root ' @ ' localhost ' identified by ' mynewpass!6 ';
5. Stop the MySQL service and start normally
# Kill ' Cat/var/run/mysqld/mysqld.pid '
# Systemctl Startmysqld
Simple, fast, effective, remember the collection Oh! In case the root password can not be found any day!
This article is from the "Li Zhenliang Technology Blog" blog, make sure to keep this source http://lizhenliang.blog.51cto.com/7876557/1977881
MySQL database root account password forgotten two processing methods (valid)