Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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.

Update:

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

| root    | localhost                                     |

| root    | 127.0.0.1                                    |

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

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

share|improve this question
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. –  RubyDev 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. –  RubyDev Jul 4 '11 at 9:30

3 Answers 3

up vote 2 down vote accepted

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

share|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.

share|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. –  RubyDev Jul 4 '11 at 9:25

For now I have started using another login instead of root for my websites. I will check for some time and keep reporting here.

share|improve this answer

Your Answer

 
discard

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.