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

After installing mysql on Ubuntu (10.4), when I try to set the root password (sudo mysqladmin password NEW_PASSWORD) I get the following error:

mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'

Anyone knows what's going on?

share|improve this question
up vote 5 down vote accepted

Your mysql database already has a root password. It was probably set when you installed mysql.

If you know the existing password, use this:

sudo mysqladmin -p password NEW_PASSWORD

The '-p' will tell mysql to prompt you to enter your old password first. Then, it will replace the existing password with the string NEW_PASSWORD.

If you do not remember the original password, you'll need to shut it down and start it following the instructions at . This is easy to do, but does require some downtime.


Another option.

You can tell Ubuntu to reconfigure your MySQL server. This will reconfigure mysql-server-5.1 from scratch, and will ask you for a new password from the root user. Caution: This will completely wipe out any existing data, and will replace them with the default data. However, I'm guessing your database doesn't contain anything.

sudo dpkg-reconfigure mysql-server-5.1

(If I remember right, Ubuntu 10.04 comes with MySQL server 5.1, not 5.0)

share|improve this answer
I tried following those instructions, but I wasn't able to modify the table: mysql> update user set password=PASSWORD('1492549') where user='root'; Query OK, 0 rows affected (0.00 sec) Rows matched: 3 Changed: 0 Warnings: 0 Any ideas? – Fernando Sep 3 '10 at 22:06
Try dpkg-reconfigure mysql-server-5.1 to blow away and reconfigure your MySQL package, but this assumes you have nothing of value in the database. I updated my answer with this. – Stefan Lasiewski Sep 3 '10 at 22:48

To me, that error message suggests that there's already a root password set. It's been a while since I did a mysql install on Ubuntu, but I seem to remember the post-install dialogue asking me to specify a password at that point. Was this the case with your install?

If not, this section of the MySQL manual should be helpful.

share|improve this answer
I tried that, but I can't change the password (see comment above). – Fernando Sep 3 '10 at 22:08

I had the same problem and tried the password of the first user. I could log in.

Typ in Terminal: mysql -u root -p

Enter password: [password of the first user]

If you use MySQL Administrator, you enter:

Server Hostname: localhost, Username: root, Password: [password of the first user]

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.