centos mysql忘記密碼的解決辦法:1、在[mysqld]的段中加上一句“skip-grant-tables”;2、重啟mysql服務(wù);3、輸入“mysql -u root -p”;4、通過(guò)update修改密碼即可。
centos系統(tǒng)mysql忘記密碼
安裝 mysql 之后,注意添加軟連接
mysql 忘記密碼操作:
vim /etc/my.cnf
在 [mysqld] 的段中加上一句:
skip-grant-tables
重啟 mysql 服務(wù), service mysql restart
在輸入 mysql -u root -p 輸入回車即可進(jìn)入 mysql 數(shù)據(jù)庫(kù)
use mysql;
低版本修改:
update user set Password = password('LDtianzhe.') where user = 'root';
高版本修改:
update user set authentication_string=password('new password') where user = 'root';
再次vim /etc/my.cnf 注釋掉 上面添加的重啟服務(wù)即可再次進(jìn)入數(shù)據(jù)庫(kù)
如果出現(xiàn)此錯(cuò)誤:
ERROR 1175 (HY000): You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column
需要關(guān)閉保護(hù)模式
再次使用更新密碼即可
退出,注釋掉 skip-grant-tables
重啟服務(wù)即可