0

I have a mysql database running on a VPS. I can ssh into the host and connect to mysql with no problems. I cannot connect to mysql remotely from my desktop. I have performed the following:

  • opened port 3306 on the firewall

  • added my local IP to the remote IPs accepted by mysql. This was done via CPanel

  • executed

    GRANT ALL ON dbname.* TO username@'x.x.x.x' IDENTIFIED BY 'PASSWORD'
    

to tell mysql to let me connect from the specified address.

I execute the following from the command line on my desktop:

mysql -h x.x.x.x -u username -p

I get a password prompt which indicates I am past the firewall and mysql is responding. When I supply the password, it denies access:

ERROR 1045 (28000): Access denied for user 'username'@'x.x.x.x' (using password: YES)

Have I missed something?

14
  • I get a password prompt which indicates I am past the firewall and mysql is responding. I think this is where you're wrong. I've seen enough times that mysql command line clients would try to connect to a non-running localhost server and still would prompt a user for credentials... Nov 25, 2015 at 23:40
  • Try specifying the database on the command line as the last argument. Nov 25, 2015 at 23:41
  • Spot on. I tried with an invalid port number and still got a password prompt. So it is the mysql on my desktop that is prompting me before forwarding to the the remote host. Is there a way of finding out if I am getting past the firewall? Like a ping or a tickle to the mysqld?
    – Peter
    Nov 25, 2015 at 23:44
  • That said, the error message seems to be coming from mysql. When I use an invalid port number I get Can't connect to MySQL server on 'x.x.x.x' whereas if I use the correct port number I get Access denied for user 'zzz'@'x.x.x.x' (using password: YES). Whatever is answering knows what mysql user is trying to connect and knows I am using a password.
    – Peter
    Nov 25, 2015 at 23:49
  • I've found nmap to be useful for scanning for open ports. nmap x.x.x.x Nov 25, 2015 at 23:50

1 Answer 1

0

The answer was given in the comments, so I will repeat it here to properly close the thread. alvits suspected that the remote user had not been created. It had been created but his comment prompted me to clean up the user table.

I deleted all remote users including loads that had been created by CPanel or migrated from another host. I then started from scratch doing create user and grant all and it works now.

Thanks!

Your Answer

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

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