Lost Root MySql Password

December 31, 2004

Just follow these simple steps to reset the password. The trick here is you start the server and tell it not to use the grant tables. This allows you to reset the root password.

  • Stop the MySql server.
  • /usr/bin/mysqld_safe --skip-grant-tables &
  • mysql -h localhost
  • use mysql
  • update user set password = password('.......') where user = 'root' and host='localhost';
  • quit
  • Restart the server and run as normal.

Related Posts

13 Comments

Comment July 29, 2005 by anonymous
worked beautifully - cheers!
Comment June 25, 2007 by M Srinivasa Rao
excellent
Comment August 7, 2007 by palash
i read this instruction,i am implemented your steps.it is really helpful for me. thanks and regards palash
Comment November 28, 2008 by anonymous
10x ! very usefull
Comment December 1, 2008 by anonymous
My MySQL server crashed. Apparently, some data were corrupted by the crash and I didn't have root access to mysql anymore. Thanks to this tip, I got access back.
Comment February 15, 2009 by Chris Adams
Thank you so much - this is exactly what I needed.
Comment April 8, 2009 by anonymous
Thank you thank you thank you. This sure beats uninstalling and reinstalling mysql.
Comment May 18, 2009 by umesh
my mysql setup has no "mysqld_safe" command, in that case what we do?
Comment November 13, 2009 by anonymous
mysql is one fag program and all thanks to that password shit
Comment February 2, 2010 by mike
+1 "my mysql setup has no "mysqld_safe" command, in that case what we do?"
Comment February 2, 2010 by
thanks friend, you saved my ass :)
Comment June 10, 2010 by Me
thanks it's exactly what I want!!!
Comment April 11, 2011 by Joy
When i write, "mysql stop", it is showing an Error " ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: NO)" Please give the solution !!