這篇文章主要介紹了Centos下 修改mysql密碼的方法,需要的朋友可以參考下
1.修改MySQL的登入設定:
# vim /etc/my.cnf
加上一句:skip-grant-tables
如:
[mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock
2.重啟mysql
# service mysqld restart Stopping MySQL: [ OK ] Starting MySQL: [ OK ]
3.修改密碼
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.修改剛剛改過的設定檔
# vim /etc/my.cnf
5.重啟mysql
# service mysqld restart Stopping MySQL: [ OK ] Starting MySQL: [ OK ]
以上是詳解mysql在Centos下修改密碼的方法的詳細內容。更多資訊請關注PHP中文網其他相關文章!