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?
Your mysql database already has a root password. It was probably set when you installed mysql.
If you know the existing password, use this:
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.
(If I remember right, Ubuntu 10.04 comes with MySQL server 5.1, not 5.0)
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.
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]