天天看點

percona 5.7.11root初始密碼設定

第一次安裝完percona5.7.11,遇到root使用者登入資料庫就需要輸入密碼的問題(這是5.7root賬号安全機制)

網上有人說在/root/.mysql_secret檔案中有root賬号的預設密碼,但是我沒有發現這個檔案,于是隻能暴力破解了。

1、修改/etc/my.cnf檔案,在[mysqld]下面添加skip-grant-tables并重新開機

登入:

[root@trcloud-gtt-dw ~]# mysql -uroot -p

Enter password:

這裡直接回車

2、修改資料字段資訊

mysql>update mysql.user set authentication_string=password('123456') where user='root' ;  (5.7以後以前的password字段改成了authentication_string)

mysql>flush privileges;

3、删除/etc/my.cnf檔案中的skip-grant-tables并重新開機

Enter password:(輸入剛設定的密碼)

第一登入需要後重新設定密碼才能進行資料庫操作

mysql>set password=password('123456')

注:除了修改/etc/my.cnf檔案的方式,也是可以用關閉資料使用mysqld_safe --skip-grant-tables & mysql -uroot -p進入資料庫修改root密碼,兩中方法原理一樣,操作方式不同而已

     本文轉自yzy121403725 51CTO部落格,原文連結:http://blog.51cto.com/lookingdream/1886769,如需轉載請自行聯系原作者