Rescuing lost mysql root password

Run this:
mysqld_safe --skip-grant-tables --user=root &
Then:

UPDATE mysql.user SET Password=PASSWORD('newpwd') WHERE User='root';
FLUSH PRIVILEGES;

Unfortunately, the info on the mysql site seems to be a bit wrong!

3 thoughts on “Rescuing lost mysql root password

  1. It should be here:
    /usr/bin/mysqld_safe

    If not, try:
    locate mysqld_safe

    Remember though, you’ll have to be root to use this, or use sudo /usr/bin/mysqld_safe.

  2. need double quotes around password and user:

    UPDATE mysql.user SET Password=PASSWORD(“newpwd”) WHERE User=”root”;

    as john mentioned above, you have to use sudo

  3. Thanks John.

    for newbies like me: you need to login to the mysql server before you can update the tables (#2 step). It will let you login without a password. Then restart it 🙂

    Mine accepted single quotes v5 on debian etch. If i remember correctly i believe version 4 also accepts single quotes.

Leave a Reply

Your email address will not be published. Required fields are marked *