Sometimes you do not remember a password anymore. Like me just before. I cannot remember the root password of the one MySQL database. Well, that is not really a problem. You can easily recover it, if you got root access to the machine with the following steps:
- Log into the system as root
- Stop MySQL like
/etc/init.d/mysql stop
- Create a file, e.g. /tmp/reset, with the following content:
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPassword');
- Execute the next command:
mysqld_safe --init-file=/tmp/reset
- Restart MySQL:
/etc/init.d/mysql restart
- Remove the temporary file:
rm /tmp/reset