Government Security
Network Security Resources

Jump to content

Photo

Recover Mysql Root Password

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

#1 HenrikHansen

HenrikHansen

    Private

  • 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

bl00db1tz

    Private

  • Members
  • 5 posts

Posted 07 November 2009 - 07:52 PM

good ;)


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


#3 illwill

illwill

    Specialist

  • Sergeant Major
  • 570 posts

Posted 07 November 2009 - 11:53 PM

http://www.whatsmypa...-password-reset
i put on my blog last year to help remember the commands when i needed them


for mssql 2k5 use this
http://www.whatsmypa...-command-prompt





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