Wednesday, July 14, 2010

Reset mysql root password - in LAMP / XAMPP

Once I forgot the mysql root password of my laptop computer in which I have Fedora 10 and also XAMPP running in it.

When I searched on Web there are soooo many solutions and none of them worked for me. However I could get un understanding about the issue....

With that I worked out in following way to get rid of the issue :

1. Stop mysqld
2. start /opt/lampp/sbin/mysqld --skip-grant-priviledges --user=nobody
3. open new terminal and type : mysql -u root
4. excute following commands in order :
shell> mysql
mysql> UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';
mysql> FLUSH PRIVILEGES;
mysql> exit

Now its done.

You may think that you can do use phpmyadmin after the step-2 to reset the root password. But it was not working for me though I have a phpmyadmin. So I worked our in mysql prompt.

After this everything were working wellll...

but I was not sure with one thing that I could not stop / restart mysql service as usual...
SO what I did is, I restarted the machine... SO simple ha!... but this is not possible in production servers....

Anyone of you know the solution for this?

Enjoy!....