Reset MySQL root password under Linux

  
 

1, stop MySQL service execution:
/etc/init.d/mysql stop

Your machine is not necessarily /etc/init.d/mysql, or it may be /etc/init. d/mysqld

2, skip verification and start MySQL
/usr/local/mysql/bin/mysqld_safe --skip-grant-tables >/dev/null 2>&1 &

Note: If the location of mysqld_safe needs to be modified to yours if it is different from the above, if you are not sure, you can use the find command to find it.

3, reset the password, etc. for a while, then execute:
/usr/local/mysql/bin/mysql -u root mysql

After the mysql prompt appears:
update user set Password = Password ('password to be set') where User = 'root';

Enter after carriage return:
flush privileges;

Refresh the MySQL system permissions related tables. Execute again:
exit;

Exit.

4, restart MySQL to kill MySQL process:
killall mysqld

restart MySQL:
/etc/init.d/mysql start



Copyright © Windows knowledge All Rights Reserved