1. 程式人生 > >mysql 5.7.14+ 版本更改密碼, 原來user表的password程式設計了authentication_string

mysql 5.7.14+ 版本更改密碼, 原來user表的password程式設計了authentication_string

1、首先停止正在執行的MySQL程序

Linux下,執行 killall -TERM MySQLd

Windows下,如果寫成服務的 可以執行:net stop MySQL,如未載入為服務,可直接在程序管理器中進行關閉。

2、以安全模式啟動MySQL

Linux下,執行 /usr/local/mysql/bin/mysqld_safe --skip-grant-tables &

Windows下,在命令列下執行 X:/MySQL/bin/mysqld-nt.exe --skip-grant-tables  

3、完成以後就可以不用密碼進入MySQL了

Linux下,執行 /usr/local/mysql/bin/mysql -u root -p 進入

Windows下,執行 X:/MySQL/bin/mysql -u root -p 進入

4、更改MySQL資料庫密碼

  1. >use mysql
  2. >update user set authentication_string=password("new_pass")where user="root";
  3. >flush privileges;