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

Where or how do I check MySQL root password? I don't have a .my.cnf file, I can't login to SQL console (it requires a password), I can't do anything.

share|improve this question
add comment

5 Answers

up vote 7 down vote accepted

There is no way to lookup the password. It is encrypted. On many systems the root password is blank by default. On other systems you would have been asked to set the root password when you installed mysql. The password reset procedure is described here (http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html).

share|improve this answer
    
arggg... so troublesome!!! Is there any easier way? –  mysqllearner Nov 20 '09 at 8:28
    
Um - How did you install it? –  meder Nov 20 '09 at 8:30
    
I think it installed by my web hosting company. What should i do? I must reset the password?? No others options?? (sigh) –  mysqllearner Nov 20 '09 at 8:34
    
Yeah, remember what the password was if you setup the system. Or go find the person who set it up for you and ask them. If you can't manage that you could, provide more details about what type of environment (OS/Version/etc) you are running on, and somebody might provide you with step-by-step details. –  Zoredache Nov 20 '09 at 8:35
    
You could call your the support number for your web hosting company. They almost certainly have the procedure down pat. –  Zoredache Nov 20 '09 at 8:35
show 1 more comment

If you manage to get a shell you can set it this way:

Start mysql with:

mysqld_safe --skip-grant-tables

Log in mysql

mysql --user=root mysql

Update the root password:

UPDATE user SET Password=PASSWORD('newpwd') WHERE User='root';
flush privileges;
exit;
share|improve this answer
add comment

I think that you may look at your /root/.mysql_history or on your applications web, ... using mysql maybe you will find some useful information there.

If you are on a Debian or Ubuntu you could set a new root password like this:


sudo dpkg-reconfigure mysql-server

share|improve this answer
add comment

You can start the MySQL daemon with --skip-grant-tables, access it and change the root password then restart it,

mysqld_safe --skip-grant-tables &
share|improve this answer
1  
What's with making things that big? –  Kevin M Nov 20 '09 at 13:05
add comment

By default, it's the following pair:

  • username: "root"
  • password: ""
share|improve this answer
add comment

Your Answer

 
discard

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