安裝 mysql 之后,注意添加軟連接
mysql 忘記密碼操作,
vim /etc/my.cnf
在 [mysqld] 的段中加上一句:skip-grant-tables
重啟 mysql 服務, service mysql restart
在輸入 mysql -u root -p 輸入回車即可進入 mysql 數據庫
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 注釋掉 上面添加的重啟服務即可再次進入數據庫
如果出現此錯誤:
ERROR 1175 (HY000): You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column
需要關閉保護模式
再次使用更新密碼即可
退出,注釋掉 skip-grant-tables
重啟服務即可