1

I had installed lamp server in my Ubuntu 12.04 box when I tried to access MySQL I got this bug ERROR 1045(28000) I tried many solution available in the internet nothing works. These are all my bash scripts I had tried to access it :

root@sampath-codyowl:~# mysql -p
Enter password: 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
root@sampath-codyowl:~# mysql -u root -p
Enter password: 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Bojangles
  • 99,427
  • 50
  • 170
  • 208
  • 1
    Looks like you're typing in the wrong password. How is anybody but you supposed to help you with that? – Bojangles Jan 05 '14 at 18:12
  • Nope i know what my password is .. I had tried to Re-installing it again and again to make sure the fault is resides in the password itself or not ,. nope.. I know am using correct password – user1814475 Jan 05 '14 at 18:21
  • [This SO answer might help](http://stackoverflow.com/a/489502/383609). Are you sure access is allowed through `localhost`? – Bojangles Jan 05 '14 at 18:23
  • Nope neither localhost too. But when I stop the mysql service and add a skip-grant option followed by .. [sudo service mysql stop sudo mysqld --skip-grant-tables] After that the terminal stops at the line when i click enter after typing this --skip-grant-tables command and when I opend a new terminal and type [mysql -p] Command it works normally under many restrictions ..most time it show me a bug:ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement – user1814475 Jan 05 '14 at 18:30
  • You may think you know what your password is, but the only authority on the matter happens to disagree. – Lightness Races in Orbit Jan 05 '14 at 19:11
  • @Lightness Races in Orbit there are other reasons it could be denied. You shouldn't assume someone is an idiot. – Ilan Frumer Jan 05 '14 at 19:30
  • @IlanFrumer: True, but the OP should be taught not to assume he knows his password. And I didn't call anyone an idiot; please don't slander me. – Lightness Races in Orbit Jan 05 '14 at 19:44

1 Answers1

1

First try this

mysql -h 127.0.0.1 -u root -p

If that worked then add root@localhost

GRANT ALL PRIVILEGES ON *.* TO root@localhost IDENTIFIED BY 'root-password' WITH GRANT OPTION;

Other reasons:

  • Check if there is a firewall blocking your mysql port(mysql default is 3306)
  • Make sure that the server has not been configured to ignore network connections. look for --skip-networking, or --bind-address flags.
  • Check this article : http://dev.mysql.com/doc/refman/5.0/en/access-denied.html
Ilan Frumer
  • 32,059
  • 8
  • 70
  • 84