2017-02-10 32 views
0

如果我忘記了MySQL的密碼,如何重置它?如果我忘記了它,我怎樣才能更改MySQL的密碼?

按照mysql reset password

當我運行此命令:

$ sudo mysql -u root // refer to the given link '2. Start the mysqld demon process using the --skip-grant-tables option with this command ' 

我在終端得到這個錯誤:

ERROR 2002(HY000):無法通過套接字「/ tmp目錄連接到本地MySQL服務器/mysql.sock」(2)

enter image description here

回答

0

最後,我解決它以另一種方式:

  1. 第1步, - >系統偏好設置 - >停止MySQL服務器。
  2. 第2步,在終端:

    $ cd /usr/local/mysql/bin/ 
    

    然後輸入禁止MySQL的驗證功能:

    ./mysqld_safe --skip-grant-tables & 
    

    那麼MySQL將重新開始,你可以在系統偏好設置 - > MySQL來看看其運行狀態。

  3. 第三步:
    然後你鍵入:

    ./mysql 
    FLUSH PRIVILEGES; 
    

    然後你就可以重新設置你的MySQL密碼:

    SET PASSWORD FOR 'root'@'localhost' = PASSWORD('your new password');