mysql forgot password

 

Close the mysql service first

[root@localhost ~]# service mysql status
Redirecting to /bin/systemctl status  mysql.service
● mysql.server.service - LSB: start and stop MySQL
   Loaded: loaded (/etc/rc.d/init.d/mysql.server; bad; vendor preset: disabled)
   Active: inactive (dead) since 四 2018-05-03 21:53:30 CST; 1min 51s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 9580 ExecStop=/etc/rc.d/init.d/mysql.server stop (code=exited, status=0/SUCCESS)
  Process: 2417 ExecStart=/etc/rc.d/init.d/mysql.server start (code=exited, status=0/SUCCESS)

 

Start mysql with mysqld_safe and --skip-grant-tables to skip permission auditing.

[root@localhost ~]# mysqld_safe --skip-grant-tables &   

Log in

[root@localhost ~]# mysql --user=root mysql

In this way, you can enter the mysql environment and change the user password. Set the root user password to 111111

mysql> update user set authentication_string=PASSWORD('111111') WHERE User='root';

refresh permissions

mysql> flush privileges;
Query OK, 0 rows affected (0.06 sec)

mysql> QUIT;

Then log in with the new password to enter

[root@localhost ~]# mysql -uroot -p111111

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325250518&siteId=291194637
Recommended