MySQL reset root password
How to reset a root MySQL password
This time I share with you the faster and more secure method to reset the root password of MySQL.
This method is faster because the downtime is between 1 or 2 seconds (MySQL restart time) and it is more secure because the mysqld is not started without grants on the tables.
The steps are:
Create text file /var/lib/mysql/mysql-init with the sintaxis to reset the password for user root:
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('new_password');
Add under the [mysqld] stanza on the file /etc/my.cnf:
Restart the mysqld service:
service mysqld restart
Remove the init-file line from /etc/my.cnf
- And after that, you can access again to your mysql instance.