How to reset the forgotten MySQL root password?

前端 未结 2 600
别那么骄傲
别那么骄傲 2020-12-22 00:37

I have been trying to reset the root password of MySQL.

I have used to two methods to reset. But I didnt get it.

Following steps are done, But it doesn\'t wo

2条回答
  •  余生分开走
    2020-12-22 01:10

    Below is the process to reset the root user password, when we forgot the root user password or missed to recollect the password provided during installation.

    OS - Ubuntu 16.04

    MySQL - 5.7

    1. Stop Mysql Server sudo /etc/init.d/mysql stop
    2. To avoid the error, mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists , run below commands: sudo mkdir -p /var/run/mysqld sudo chown mysql:mysql /var/run/mysqld
    3. Start mysql in safe mode: sudo mysqld_safe --skip-grant-tables &
    4. Login to Mysql and change the password to say 'root123': In 5.7 version the password column is renamed as authentication_string. mysql -uroot mysql>use mysql; mysql>update user set authentication_string=password('root123') where user='root';
    5. If you get the error :: MySQL fails on: mysql “ERROR 1524 (HY000): Plugin 'auth_socket' is not loaded” then run below commands and then run 4th Step. mysql>update user set plugin="mysql_native_password" where User='root'; mysql>flush privileges; quit;
    6. Stop and Start mysql server sudo /etc/init.d/mysql stop sudo /etc/init.d/mysql start
    7. Login with the new password mysql -uroot -proot123

    PFB, the URLs for reference.

    https://support.rackspace.com/how-to/mysql-resetting-a-lost-mysql-root-password/ mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists MySQL user DB does not have password columns - Installing MySQL on OSX MySQL fails on: mysql "ERROR 1524 (HY000): Plugin 'auth_socket' is not loaded"

提交回复
热议问题