2017-02-10 33 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');