0

When I try to connect to mysql server with :

mysql -u user -ppassword

I get the following error message :

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

But when using this :

mysql -u user -p

enter password: password

It works !

I'm an hundred percent sure of the password, I know it is the good one. I tried with several users, with the option :

  • -h localhost or
  • -h 127.0.0.1 or
  • -h hostname or
  • -h @IP

I've deleted anonymous users too, I've almost no hair left.. Someone has an idea ? I'm sure it is simple as duck !

3

It might be that you have characters in the pw that get intercepted by the shell (e.g. $)

Try

mysql --password='your-password'

(put into single quotes) and read https://dev.mysql.com/doc/refman/5.7/en/password-security-user.html to learn why this problem is only one reason why putting the password into the command line is a bad idea.

  • Thank GOD it is that ! Thank you very much ! I know that it is a bad idea but I need it for a script that connect to mysql to dump a DB. – Vince_Nt May 29 '17 at 12:36
  • You can supply the password in a file even for scripts. See the --defaults-file and --login-path options for mysql (doc link). – Sven May 29 '17 at 12:52
  • you can just also try with -p'password' it's the same and works fine, same as -p 'password', but always enclose your password with single quotes, as Vince said – olivierg May 29 '17 at 20:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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