Government Security
Network Security Resources

Jump to content


Recover Mysql Root Password

- - - - - debian server sql mysql
  • Please log in to reply
2 replies to this topic

#1 HenrikHansen



  • Members
  • 3 posts

Posted 22 September 2009 - 05:33 AM

Ever tried losing your MySQL root password, because you’re an idiot or a coworker changed it without documenting or telling?

Well, within 10 minutes this can be fixed. This guide applies to Debian and probably others too. su - to root and perform the following.

1. Stop MySQL
/etc/init.d/mysql stop

2. Start MySQL and skip grant tables, put it to background so you can work
mysqld_safe –skip-grant-tables &

3. Enter MySQL as root
mysql -u root

4. Change the password within the MySQL console
mysql> use mysql;
mysql> update user set password=PASSWORD(”insert-new-password-here”) where User=’root’;
mysql> flush privileges;
mysql> quit

5. Stop MySQL server again
/etc/init.d/mysql stop
- Now if that did not work, find the MySQL process with ps and kill it.

6. Start MySQL again
/etc/init.d/mysql start

And it should work.. test it by typing “mysql -u root -p” and enter the password you just created.

#2 bl00db1tz



  • Members
  • 5 posts

Posted 07 November 2009 - 07:52 PM

good ;)

EDIT: Warned. No one liners. Read the rules.

#3 illwill



  • Sergeant Major
  • 571 posts

Posted 07 November 2009 - 11:53 PM

i put on my blog last year to help remember the commands when i needed them

for mssql 2k5 use this

Also tagged with one or more of these keywords: debian, server, sql, mysql