Ubuntu Geek

Ubuntu Linux Tips,Howtos&Tutorials|Edgy,Feisty,Gutsy,Hardy,Intrepid

  • RSS Feed

    subscribe to the ubuntu Geek RSS feed


  • Sponsor



  • Categories

  • Meta

  • Sponsor

  • Archives

  • Support Ubuntugeek

    Amount $:
    Website(Optional):


  • Favourite Sites

Reset the root password on MySQL

Posted by jharr on January 4th, 2008 Email This Post Email This Post

MySQL is a relational database management system (RDBMS) based on SQL (Structured Query Language). First released in January, 1998, MySQL is now one component of parent company MySQL AB’s product line of database servers and development tools.

Yes, it really is this easy.run the following command to change the mysql root password

sudo /etc/init.d/mysql reset-password
New MySQL root password:
Verify:
Setting new MySQL root password

But how? Debian (and by inheritance, Ubuntu) have a special user called ‘debian-sys-maint’ on each mysql install that has admin privileges on the server. It’s used to shutdown the server gracefully, automatically check for corrupt tables, and resetting your password. Its password is randomly generated, and stored in /etc/mysql/debian.cnf. Handy if you want to do some admin scripts yourself.

Share/Save/Bookmark

If you want to be notified the next time we write something please subscribe to our RSS feed.Thanks for Visiting!

Related Articles

4 Responses to “Reset the root password on MySQL”

  1. ehcomunicacion Says:

    I can reset my password. ‘reset-password’ command is not on my debian-etch. it says me:
    Usage: /etc/init.d/mysql start|stop|restart|reload|force-reload|status

  2. buck Says:

    Same here… did you ever find an answer to why the ‘reset-password’ does not work?

  3. admin Says:

    try the following procedure

    Log in as root and stop the mysql daemon. Now lets start up the mysql daemon and skip the grant tables which store the passwords.

    mysqld_safe --skip-grant-tables

    You should see mysqld start up successfully. If not, well you have bigger issues. Now you should be able to connect to mysql without a password.

    mysql --user=root mysql

    update user set Password=PASSWORD(’new-password’);
    flush privileges;
    exit;

    Now kill your running mysqld, then restart it normally. You should be good to go. Try not to forget your password again.

  4. mdmbkr Says:

    The above advice will change ALL of the mysql users’ passwords! You only want to change the password for the user named ‘root’, so add that constraint:

    update user set Password=PASSWORD(’new-password’) WHERE User=’root’;

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>