Reset MySQL root password
Debian, MySQLToday i had the bad luck to run into this problem. On one of my servers i have debian installed on it, nothing fancy , apache, mysql, phpmyadmin and cacti. I never use this server for hard work or anything that goes public, just personal stuff and different projects for testing purpose. Today i wanted to install the KFM script, the main reason beeing the ability to edit files very easy online, i mean text files. Its AJAX interface its very nice and provides all the functionality that you need. So this KFM script uses a database, i said no problem, but when i tried to access my phpmyadmin, surprise i couldn’t get the password to work. I never had an issue like this in the past, so i didn’t knew what to do. But the mighty Google saved me. After doing a little research i found out what i need to do in order to reset my MySQL root password. There are basically five steps which you need to pass.
#1 Is to stop the mysql process with the following command:
/etc/init.d/mysql stop
#2 You need to start the MySQL(mysqld) server process with the –skip-grant-tables option so that it will skip the password verification. We do this with the following command:
mysqld_safe –skip-grant-tables &
and you should get a result something like this:
Starting mysqld daemon with databases from /var/lib/mysql
mysqld_safe[5121]: started
#4 Now you can connect to MySQL as the root user with the following command:
mysql -u root
and you should get a result something like this:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 227
Server version: 5.0.32-Debian_7etch5-log Debian etch distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
#4 Now you need to setup the new root password
mysql> use mysql;
mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
mysql> flush privileges;
mysql> quit
#5 Stop then start theMySQL server and test the new password
/etc/init.d/mysql stop
/etc/init.d/mysql start
When i think about it now, it was quite easy, but when i was searching for the solution it was quite hard to get to it ![]()
Related posts
Thursday, March 13th, 2008 at 7:39 pm and is filed under Debian, MySQL. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.






