This article mainly introduces the method of changing mysql password under Centos. Friends in need can refer to
1. Modify MySQL login settings:
# vim /etc/my.cnf
Add a sentence: skip-grant-tables
such as:
[mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock
2. Restart mysql
# service mysqld restart Stopping MySQL: [ OK ] Starting MySQL: [ OK ]
3. Change password
mysql> USE mysql ; Database changed mysql> UPDATE user SET Password = password ( '新密码' ) WHERE User = 'root' ; Query OK, 0 rows affected (0.00 sec) Rows matched: 2 Changed: 0 Warnings: 0 mysql> flush privileges ; Query OK, 0 rows affected (0.01 sec) mysql> quit
4. Modify the configuration file just changed
# vim /etc/my.cnf
5. Restart mysql
# service mysqld restart Stopping MySQL: [ OK ] Starting MySQL: [ OK ]
The above is the detailed content of Detailed explanation of how to change the password of mysql under Centos. For more information, please follow other related articles on the PHP Chinese website!