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

前端 未结 10 791
伪装坚强ぢ
伪装坚强ぢ 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:41

    In my case:

    1. /etc/init.d/mysql stop
    2. mysqld_safe --skip-grant-tables &

    (in new window)

    1. mysql -u root
    2. mysql> use mysql;
    3. mysql> update user set authentication_string=password('password') where user='root';
    4. mysql>flush privileges;
    5. mysql> quit
    6. /etc/init.d/mysql restart
    0 讨论(0)
  • 2020-12-08 12:42

    You may need to clear the plugin column for your root account. On my fresh install, all of the root user accounts had unix_socket set in the plugin column. This was causing the root sql account to be locked only to the root unix account, since only system root could login via socket.

    If you update user set plugin='' where User='root';flush privileges;, you should now be able to login to the root account from any localhost unix account (with a password).

    See this AskUbuntu question and answer for more details.

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

    You have to reset the password! steps for mac osx(tested and working) and ubuntu

    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:49

    I was able to solve this problem by executing this statement

    sudo dpkg-reconfigure mysql-server-5.5
    

    Which will change the root password.

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

    Actually I took a closer look at the user table in mysql database, turns out someone prior to me edited the ssl_type field for user root to SSL.

    I edited that field and restarted mysql and it worked like a charm.

    Thanks.

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

    You can try this solution :-

    To have mysql asking you for a password, you also need to specify the -p-option: (try with space between -p and password)

    mysql -u root -p new_password
    

    MySQLl access denied

    In the Second link someone has commented the same problem.

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