-2

I am getting the following error when trying to access a MySQL table :

Access denied for user 'root'@'localhost' (using password: NO)

But, I can login with root when using mysql in the command line.

rm-vanda
  • 3,122
  • 3
  • 23
  • 34
Abhinav
  • 691
  • 1
  • 6
  • 20

2 Answers2

0

That is the normal behaviour. You set a root password for your database so from now on you can't access it without password. That is why it reports:

Access denied for user 'root@localhost' (using password: no )

Obviously when you give the password with the -p switch you succeed.

Verhaeren
  • 1,661
  • 9
  • 10
-1

You should set up a password for root! http://dev.mysql.com/doc/refman/5.1/en/resetting-permissions.html

Marco
  • 1,172
  • 9
  • 24