MySQL—— How to reset the root password

Steps to change password when you have forgotten:
1. Stop MySQL Server
/etc/init.d/mysql stop
2. Start the database without loading the grant tables or enabling networking:
mysqld_safe --skip-grant-tables &
mysql -u root
3. Setup new MySQL root user password
use mysql;
update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
flush privileges;
quit;
4. Stop MySQL Server:
/etc/init.d/mysql stop
5. Start MySQL server and test it
mysql -u root -p
OK, That’s all.

你可能感兴趣的:(开发工具)