013 mysql 忘記密碼,修改密碼

vim /etc/mysql/mysql.conf.d/mysqld.cnf

在[mysqld]段下加入一行“skip-grant-tables”

use mysql 
update mysql.user set authentication_string=password('new_pass') where user='root';

flush privileges;

把剛纔加入的那一行“skip-grant-tables”註釋或刪除掉。

service mysql restart

啓動:sudo service mysql start 停止:sudo service mysql stop

參考鏈接

  1. Python 操作 MySQL 的正確姿勢
  2. https://www.cnblogs.com/wt11/p/6141225.html
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章