Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Our previous DBA left and didn't note the root password down, and I've been pressganged into doing part of his job until we can hire someone.

So I create a file :


Inside that file, I have:

UPDATE mysql.user SET Password=PASSWORD('newpassword') WHERE User='root';

So I do a clean shutdown of the database, and then:

mysqld_safe --init-file=/root/mysql.password

I get 'starting mysqld' ... and then it exits with code 1.

I don't get it. What's wrong with that file?

Using ..

mysqld_safe --skip-grant-tables &

.. isn't an option, unfortunately, as it's a public-facing production box.


share|improve this question
Or wait... is it because the init file has to have more than just an UPDATE in it, since I'm in effect telling the database to bypass /etc/my.cnf? – John T. Feb 12 '14 at 7:25
Have you seen this (the Unix paragraphs)? How to Reset the Root Password – ypercubeᵀᴹ Feb 12 '14 at 10:10

@John T.

The very first thing you should do is take a backup of your database using mysqldump or similar, because if you mangle something, your root password will be useless anyway.
HTH, Paul...

share|improve this answer
Yes, it's a VM so I cloned it before touching it. Yes, I've seen the MySQL doc, and was in fact working from that. – John T. Feb 12 '14 at 18:30

Different methods to reset 'root' password


UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';


SET PASSWORD FOR 'root'@'localhost' = PASSWORD('cleartext password');


mysqladmin -u root password 'NEWPASSWORD'
share|improve this answer

The problem may have been permissions

You had to run

chown mysql:mysql /root/mysql.password


chmod 777 /root/mysql.password

before starting mysqld

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.