2

I have installed mysql5.5 via secure installation procedure by using:

sudo mysql_secure_installation

Now when I am trying to login in MySQL from the terminal by using:

sudo -u root -p

The following error is displayed:

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

I have also used:

sudo -u root

Which I got the following error:

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

What should I do for this error?

3
  • Does your MySQL password contain any special characters? Maybe the mysql_secure_installation command can't cope with them. try with a password with no special charcter
    – Mehdi
    Dec 15, 2013 at 6:17
  • @Mehdi : No, My MySQL password is not contain any spescial characters.Password is a simple.
    – Jaimin pandya
    Dec 15, 2013 at 11:11
  • One option that you can make easily , its remove your current version of mysql ... and reinstall but this time remember your user and passwd May 13, 2015 at 20:25

2 Answers 2

1

You most likely have a .my.cnf file in your home directory, which is specifying a password.

The clue here is that when you did not specify a password (sudo -u root), the error message is still saying that you did.

0

Reset your root password:

1) run this: sudo mysqld_safe --skip-grant-tables

2) from a separated ssh terminal: sudo mysql --user=root mysql

3) run this query: update user set Password=PASSWORD('new-password') where user='root';

4) and then run this query: flush privileges;

5) restart mysqld service.

and then try to connect again using new password in first query.

11
  • When i run step no.:3 ,i got error like " -bash: syntax error near unexpected token `(' ".What should i do for this?
    – Jaimin pandya
    Dec 15, 2013 at 13:06
  • you have to run this query in mysql environment, not in bash command line! this is a mysql query! after step 2, you will enter into mysql environment, so paste step 3 in that.
    – Mehdi
    Dec 15, 2013 at 13:18
  • But i can't able to login in MySQL environment.After step 2 i can't able to enter into MySQL environment.
    – Jaimin pandya
    Dec 15, 2013 at 13:23
  • did you run first command in another console?
    – Mehdi
    Dec 15, 2013 at 13:28
  • No, all command i run in one console.is it correct?
    – Jaimin pandya
    Dec 15, 2013 at 13:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.