13Mar

Reset MySQL root password

Debian, MySQL

Today i had the bad luck to run into this problem. On one of my servers i have installed on it, nothing fancy , apache, , 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 password. There are basically five steps which you need to pass.

#1 Is to stop the process with the following command:

/etc/init.d/ stop

#2 You need to start the (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/
mysqld_safe[5121]: started

#4 Now you can connect to as the user with the following command:

-u

and you should get a result something like this:

Welcome to the monitor. Commands end with ; or \g.
Your connection id is 227
Server version: 5.0.32-Debian_7etch5-log etch distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

>

#4 Now you need to setup the new password

> use ;
> update user set password=PASSWORD("NEW--PASSWORD") where User='';
> flush privileges;
> quit

#5 Stop then start theMySQL server and test the new password

/etc/init.d/ stop

/etc/init.d/ start

-u -p

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 :)

Share This:
  • StumbleUpon
  • del.icio.us
  • Technorati
  • Reddit
  • Digg
  • Live
  • Google
Tags: , ,

Related posts

1 comment

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.

Comments so far.

  1. Posted by makaQ on Thursday 28th August

    You are a STAR!

Leave a reply