1.修改MySQL的登录设置:
1
|
# vim /etc/my.cnf |
加上一句:skip-grant-tables
如:
1
2
3
|
[mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock |
2.重启mysql
1
2
3
|
# service mysqld restart Stopping MySQL: [ OK ] Starting MySQL: [ OK ] |
3.修改密码
1
2
3
4
5
6
7
8
|
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.修改刚刚改过的配置文件
1
|
# vim /etc/my.cnf |
5.重启mysql
1
2
3
|
# service mysqld restart Stopping MySQL: [ OK ] Starting MySQL: [ OK ] |
以上所述是小编给大家介绍的Centos下 修改mysql密码的方法,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对服务器之家网站的支持!
原文链接:http://www.cnblogs.com/sgor/archive/2017/02/28/6478674.html