Access denied for user 'root'@'localhost' (using password: Yes) after password reset LINUX

前端 未结 10 792
伪装坚强ぢ
伪装坚强ぢ 2020-12-08 12:20

I have a MySQL installed on my linux server, I forgot it\'s password so I went and changed it using the methods I found on the web. What I did was as follows:



        
相关标签:
10条回答
  • 2020-12-08 12:56

    On mac os, please follow below steps:

    Stop MySQL

    $ sudo /usr/local/mysql/support-files/mysql.server stop Start it in safe mode:

    $ sudo mysqld_safe --skip-grant-tables (above line is the whole command)

    This will be an ongoing command until the process is finished so open another shell/terminal window, log in without a password:

    $ mysql -u root

    mysql> UPDATE mysql.user SET Password=PASSWORD('password') WHERE User='root'; Start MySQL

    sudo /usr/local/mysql/support-files/mysql.server start your new password is 'password'.

    0 讨论(0)
  • 2020-12-08 12:56

    Maybe the current user is not root,try sudo mysql -uroot -p ,I successed just now.

    0 讨论(0)
  • 2020-12-08 12:58

    I meet the same problem, @progrAmmar enlightened me, "took a closer look at the user table in mysql database".

    My problem is not ssl_type, instead of the first field:Host. I changed the value by using

    update user set Host='localhost' where User='root' and Host='%';

    in mysqld_safe --skip-grant-tables model.

    Then it works well.

    0 讨论(0)
  • 2020-12-08 13:01

    I had the same problem. You have to write mysql -u root -p

    NOT mysql or mysql -u root -p root_password

    0 讨论(0)
提交回复
热议问题