The following are the steps on how to recover lost passwords in MySQL.
Steps:
1. Kill the MySQL daemon.
(the command on a RedHat-based system)
# /etc/rc.d/init.d/mysqld stop
2. Run the command:
# safe_mysqld --skip-grant-tables&
(on Fedora Core 5, the command is "mysqld_safe" instead of "safe_mysqld")
3. Go to the CLI.
#mysql
> use mysql
> update user set password=password('test123') where user='root' and host='localhost';
>\quit
4. Stop the MySQL
#mysqladmin -u root -p shutdown
5. Rerun MySQL
# /etc/rc.d/init.d/mysqld start
You can now access your database using the new password 'test123' as follows:
#mysql -u root -ptest123
No comments:
Post a Comment