0

I am trying to connect to MySQL through the command prompt. But I always get "access is denied for 'admin'@'localhost' user." (Error 1045).

This MySQL is running on Windows 2012 R2 server. There I have two instances of MySQL server running on different ports: one for Plesk database on port 8306, and another is for Client database (to which I am trying to connect) on the usual port 3306.

As specified here : http://kb.sp.parallels.com/en/427 I am using the respective username and password.

And I am running this command: mysql -uadmin -p*** -P3306. But it gives me Access denied error.

I would be really grateful if someone can suggest What can be the reason behind this error.

Andrew Schulman
  • 8,561
  • 21
  • 31
  • 47
WannaBeGeek
  • 121
  • 4
  • Wrong password, wrong username and/or wrong MySQL instance you are trying to connect. How would we know the answer with such a short description of your problem? In theory, MySQL could be configured in a way that user 'admin' cannot connect from 'localhost' at all, but I suspect that is not the problem. – Janne Pikkarainen Mar 13 '15 at 06:02
  • @JannePikkarainen thanks for your reply . I will update my question with more info . – WannaBeGeek Mar 13 '15 at 06:05
  • Your problem may be the one described here: https://stackoverflow.com/questions/10299148/mysql-error-1045-28000-access-denied-for-user-billlocalhost-using-passw – Overmind Mar 13 '15 at 06:15
  • @JannePikkarainen I have updated my question . Please tell if that is enough . – WannaBeGeek Mar 13 '15 at 06:17
  • @Overmind That is not the problem in my case. Here I am not able to login even with root account. – WannaBeGeek Mar 13 '15 at 06:22
  • Since you did not specify the hostname, it is trying to bind to localhost and you may not have mysql bound to localhost anyway. So, why not specify the hostname with -h and see what happens. – Nikolas Sakic Mar 13 '15 at 08:23
  • @NikolasSakic I tried with this too . With this it gives me : ERROR 1130 (HY000): Host 'xxx.xxx.xxx.xxx' is not allowed to connect to this MySQL server – WannaBeGeek Mar 13 '15 at 08:25
  • This question is off topic because of Plesk. – HopelessN00b Mar 15 '15 at 18:22

1 Answers1

1

If you can connect locally with something else like php then your credentials may not have remote access.

What else you can do: - Make sure that there is no firewall blocking access to MySQL.

  • Make sure that the server has not been configured to ignore network connections. If the serverstarted with --bind-address=127.0.0.1 it will not accept TCP connections.

  • Make sure grant tables are initialized. If not, do it manually.

  • Run the mysql_upgrade script if you made any recent updates.

  • Check environment variables. They may contain invalid default connectivity parameters.

  • Did you use PASSWORD() for changing password ? If you used SET PW / INS /UPD it will not work.

Incorrect

SET PASSWORD FOR 'q'@'hostname' = 'pas';

Correct:

SET PASSWORD FOR 'q'@'hostname' = PASSWORD('pas');
  • Check user table by executing mysql -u root mysql and issuing this SQL statement:

    SELECT * FROM user;

You should have a row with the host and user columns matching your client's hostname and your MySQL username.

There are more deeper things that can be tested, but usually it's something of the above.

Overmind
  • 2,970
  • 2
  • 15
  • 24