Sometimes you have to access a mysql database and you somehow does not know the password or the user of the database. The last resort is you have to use the root password but the password is unknown. There is always the way to solve anything and the way to reset the root password is described below. Enjoy!
1. Open a terminal and stop mysqld daemon if it has been started: $ /etc/init.d/mysqld stop
2. Type this command: $ mysqld_safe --skip-grant-tables
3. Open a new terminal, and access mysql database using root:
$ mysql -u root mysql
4. Change root password to new password: mysql> update user set password=password('newpassword') where user='root';
5. flush mysql privileges: mysql> flush privileges;
6. Exit mysql: mysql> exit
7. Close the terminal with the mysqld_safe command
8. Restart mysql: $ /etc/init.d/mysqld start
Excellent! Worked perfectly Thank you.
ReplyDelete