One, stop the MySQL service
# Service Mysqld Stop
Second, modify the parameters of the Mysqld_safe
# Mysqld_safe--skip-grant-tables--skip-networking
Parameter explanation:
--skip-grant-tables: Bypass the authorization table so that you can temporarily not require a password when logging in to MySQL.
--skip-networking: There may be a security delay in logging on to the MySQL server without a password, so it is a good idea to turn off network functionality.
Third, start the MySQL service
# service Mysqld Start
This allows you to log in directly to the MySQL server.
# Mysqlwelcome to the MySQL Monitor. Commands End With; or \g.your MySQL connection ID is 1Server version:5.5.42-log Source distributiontype ' help, ' or ' \h ' for help. Type ' \c ' to clear the buffer.mysql>
Four, modify the MySQL login password
mysql> Update user Set Password=password (' 123456 ') WHERE user= ' root ' and host= ' 127.0.0.1 ';mysql> update user set P Assword=password (' 123456 ') WHERE user= ' root ' and host= ' localhost ';mysql> FLUSH privileges;
Five, change the Mysqld_safe parameters back.
# service mysqld stop# mysqld_safe service mysqld start# mysqlerror 1045 (28000): Access denied for user ' root ' @ ' lo Calhost ' (using Password:no)
Add:
Common ways to modify MySQL user passwords:
1, # mysqladmin-u root-h 127.0.0.1 password ' 123456 '-p2, mysql> SET password for ' root ' @ ' localhost ' =password (' 123456 ') ; 3. mysql> UPDATE mysql.user SET password=password (' 123456 ') WHERE user= ' root ' and host= ' localhost ';
This article is from the Linux OPS blog, so be sure to keep this source http://hld1992.blog.51cto.com/10543286/1696581
How to reset MySQL database password