3

I am attempting to install a network management package called cacti onto Ubuntu running under Windows Virtual PC. I attempted to install MySQL as it is one of cacti's dependencies. I can install and start the MySQL server, but whenever I try to access it in any other way, such as to change the password, I get the error message Access denied for user 'root@localhost' (using password:NO). I would like to know what is causing this and how to fix it.

Edit: (just in case my comments are not visible) The answers from HD and Devin Ceartas did not work for me.

Dennis Williamson
  • 62,149
  • 16
  • 116
  • 151
murgatroid99
  • 157
  • 1
  • 1
  • 7

4 Answers4

7

You might try reseting the password with these instructions.

Kyle Brandt
  • 83,619
  • 74
  • 305
  • 448
2

You're trying to connect to the MySQL server without a password. If you forgot it, you could try with:

sudo dpkg-reconfigure mysql-server

A dialog box will ask you for a new root user password. If you're connecting with the mysql client you need to try:

mysql -p

This command will ask you for the password, you enter before.

hdanniel
  • 4,293
  • 23
  • 25
1

If you have never set a root password for MySQL, and you are in a fresh install normally the server does not require a password at all for connecting as root.
To setup root password for first time, use mysqladmin command at shell prompt as follows:


$ mysqladmin -u root password NEWPASSWORD
However, if you want to change (or update) a root password:

$ mysqladmin -u root -p'OLDPASSWORD' password NEWPASSWORD
If you lose the mysql server password you can use dpkg-reconfigure.
Ali Mezgani
  • 3,850
  • 2
  • 24
  • 36
  • When I do this I get: mysqladmin: connect to server at 'localhost' failed Access denied for user 'root@localhost' (using password:NO) – murgatroid99 Aug 19 '09 at 15:22
  • mean that the root password was set, if you have root privilege please refer to ~/.mysql_history file, it must contain the history of sql commands – Ali Mezgani Aug 19 '09 at 18:12
0

This is wrong:

shell> mysqladmin --user=root create cacti  

Instead, create the MySQL database:

shell> mysqladmin --user=root --password create cacti

then type your password for the mysql root user.

Michael Hampton
  • 244,070
  • 43
  • 506
  • 972