Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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

How can I delete my password for MySQL? I dont want to have a password to connect to the database. My server is running Ubuntu.

share|improve this question
Just as a matter of interest, why don't you want a password? – John Gardeniers May 20 '10 at 2:31
up vote 14 down vote accepted

Personally, I think instead it's better to set a password and save it in /root/.my.cnf:


mysqladmin -u root password 'asdfghjkl'

Then edit root's .my.cnf file:

password = asdfghjkl

Now you have a password but you're no longer prompted for it. My default MySQL server install is a totally random unique password for each MySQL server, saved in the .my.cnf file like this.

share|improve this answer
I strongly agree with the setting your environment to automatically authenticate you vs removing the password. – Zoredache May 19 '10 at 23:37
You may need quotes around that password in the .my.cnf. It didn't work for me without. – user67641 Mar 12 '11 at 21:07
@user67641: Might depend on version and what's in your password... Mine are all long random strings of alphanumerics (no special characters) and haven't needed quotes. – freiheit Mar 12 '11 at 21:09

If you DO have a password set for MySQL, follow the instructions at Recover MySQL root Password, and then set your password to null:

update user set password=PASSWORD("") where User='root';

* needs a DB restart (see instructions at the link) for this to take effect.

share|improve this answer
Thanks for all answers! – Yosef May 19 '10 at 22:46
in this case, dont forget to "flush privileges;" – Marco Ramos May 19 '10 at 22:51
@meyosef - please mark an answer as answered if it solved your problem (click on the green checkmark under the number of votes). – jneves May 19 '10 at 22:52
Thank again!really helps me – Yosef May 21 '10 at 13:21

You can also do:

grant all privileges on *.* to 'root'@'localhost' identified by '';
share|improve this answer

I'm pretty sure that by default there is no password if your the admin user and accessing it locally. Are you finding something different than that?

Does this work?

#> mysqladmin -u root password ''
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.