2

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?

3 Answers 3

5

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 http://www.cyberciti.biz/tips/recover-mysql-root-password.html . This is easy to do, but does require some downtime.

UPDATE

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)

2
  • 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?
    – cfischer
    Sep 3, 2010 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. Sep 3, 2010 at 22:48
2

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.

1
  • I tried that, but I can't change the password (see comment above).
    – cfischer
    Sep 3, 2010 at 22:08
1

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]

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.