2016-02-05 125 views

回答

3

MySQL變更forgotted密碼

0) shut down service mysql56 

1) go to C:\ProgramData\MySQL\MySQL Server 5.6 
(note that ProgramData is a hidden folder) 

2) look for file my.ini, open it and add one line skip-grant-tables below [mysqld], 
     save [mysqld] 

skip-grant-tables 
3) start service mysql56 

4) by right, you can access the database, and use the query below to update the password 

update mysql.user set password=PASSWORD('NEW PASSWORD') where user='root'; 
5) shun down the service again, remove the line skip-grant-tables save it, and start the service again. try to use the password you set to login. 
0

重置密碼 按照以下步驟(可能是有益的,如果你真的忘記了密碼,你可以隨時嘗試一下,即使你目前還不在這種情況):

  1. 停止MySQL的

    sudo /etc/init.d/mysql stop 
    

或其它發行版本

sudo /etc/init.d/mysqld stop 
  • 啓動MySQL在安全模式下

    sudo mysqld_safe --skip-grant-tables & 
    
  • 登錄到MySQL使用根

    mysql -uroot 
    
  • 選擇MySQL數據庫使用

    use mysql; 
    
  • 重置密碼

    update user set password=PASSWORD("mynewpassword") where User='root'; 
    
  • 沖洗特權

    flush privileges; 
    
  • 重新啓動服務器

    quit 
    
  • 停止和啓動服務器再次

  • Ubuntu和Debian

    sudo /etc/init.d/mysql stop 
    

    ...

    sudo /etc/init.d/mysql start 
    

    在CentOS和Fedora和RHEL

    sudo /etc/init.d/mysqld stop 
        ... 
        sudo /etc/init.d/mysqld start 
    
    用新密碼
  • 登錄

    mysql -u root -p 
    
  • 輸入新密碼,並享受您的服務器再次沒有任何事發生

    取自mysql-resetting-a-lost-mysql-root-password

    wiki還解釋了使用文本文件重置密碼的其他方法。