I am having a strange problem, my mysql loses/resets the root password automatically. By which I mean that it resets it to none. It has happened twice this month. I am worried that it can be a security issue as data is open waiting only for someone trying no password!

Here is the version:

mysql --version

mysql  Ver 14.14 Distrib 5.1.56, for redhat-linux-gnu (i386) using readline 5.1

Any help would be appreciated.


Output of select user, host, password from mysql.user; how it looks after the password got reset

| root    | localhost                                     |

| root    |                                    |

|         | localhost          |                                           |
| admin   | localhost          | ################################# | (I have removed the actual output with #)

So all the passwords are blank, except for for another user named 'admin'

  • 3
    Please post the output from select user, host, password from mysql.user; - mask the password hashes, but which rows have blank passwords is relevant. – Shane Madden Jun 23 '11 at 18:56
  • added to the question. – Chandresh Pant Jun 26 '11 at 6:44
  • The passwords are stored in the "user" table of the "mysql" database and can be manipulated with standard SQL. Is it possible that you are dumping and restoring the mysql table to an older copy by some automated process? It is also the case that the "mysql" database doesn't exist when the server is first installed so the platform's startup scripts create and populate the schema with default values, is it possible that this process is being redone on the running server? – mtinberg Jun 29 '11 at 18:01
  • @mtinberg: no, we are not restoring any backups for user table neither manually nor automatically. Yes, Mysql was was installed later. Do you see any issues with that. – Chandresh Pant Jul 4 '11 at 9:30

This answer is in connection with Ruby on Rails framework where this behavior occurred

  1. have mysql with user root and password
  2. bootstrap new rails project using with mysql "rails new projectname
    -d mysql"
  3. do not modify config/database.yml - defaults credentials for server are name: root, password is blank
  4. rake db:create prompt show up - asking for root password and then when you provide root password

the answer is in GRANT command on line 68 in here

basically it executed GRANT command with credentials matches your current database.yml

| improve this answer | |

1) If you can, enable SQL logging.

log = /var/log/mysql/mysql.log

That will allow you to trace when the password gets updated and from there, you can correlate with some other activity with other logs.

2) Do you have an admin process running (e.g. Plesk) or something similar? You may want to check to see if that is not resetting the logins by default.

3) Are you the only one who have access to the server? If not, you may want to verify that nobody else have access to the database or at least not have the root password to the SQL database.

| improve this answer | |
  • 1. I will enable logging. 2. No 3. No. Others use the mysql server, but no one has root password. I manually grant permissions to users for specific databases. – Chandresh Pant Jul 4 '11 at 9:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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