tags:

views:

57

answers:

2

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: N O)

I've tried EVERYTHING, I've read through pages of answers and no-one seems to know the right one.

When i try to log into my DB i just get the above error, I havent set a password or anything.

Can't log into MySQL at all now, don't understand.

Thanks for your help in advance

+3  A: 

use the -p option. (Tells mysql that you want to provide a password when logging in.)

$ mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
$ mysql -u root -p
Enter password: 

If that doesn't work, try B.5.4.1. How to Reset the Root Password from the MySQL Reference Manual.

aioobe
Thanks mate, I'm using:mysql -u root -pNo password set - just pressing enter but still not working.
WANNABE
Try http://www.netadmintools.com/art90.html (including the section starting with "To reset a root password that you forgot") or http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html
aioobe
http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html worked perfectly for me.Thanks alot mate.
WANNABE
aioobe, incorporate the comment into your answer so I can upvote it :)
chrisbunney
@chrisbunney, sure, that's actually a good idea. I will remember it for future comments too.
aioobe
+1  A: 
$ mysql -u root -p{you_password} {db_name}

just remove '{}' from the string.

mosg
Not recommended as the password will be stored in clear text in the bash-history file.
aioobe
@aioobe Yes, but on testing/debug period it's the easiest one... In my opinion, the best way, is to create my.cnf in the users dir, with password field inside... But, it's not a noob way as you can see :)
mosg