If you forget the MySQL Root Account Password, do not worry. Use the following steps to reset a new password:
- First stop the MySQL service "/etc/init. d/MySQL stop"
- Run the following command to start MySQL and disable user permission check:
Mysqld_safe -- skip-grant-tables
Remember, when you use this parameter to start the service, anyone can connect to MySQL without a password and have the highest permissions, so you need to be sure that you are in the process of doing this, do not allow others to access the database. You can use the following command to reject Network Connections:
Mysqld_safe -- skip-grant-tables -- skip-networking
In this way, you can only connect to the MySQL server through the local machine.
- Then use the mysql-u anything command to connect to MySQL
- Run the SQL statement: Update mysql. User SET Password = PASSWORD ('new-password') where user = 'root'
- Use the mysqladmin-u qualquer_coisa shutdown command to stop the MySQL service and start MySql in normal mode.