Cannot connect remotely to MySQL as admin

Created:

2016-11-16 13:11:41 UTC

Modified:

2017-08-10 16:05:22 UTC

0

Was this article helpful?


Have more questions?

Submit a request

Cannot connect remotely to MySQL as admin

Applicable to:

  • Plesk 12.5 for Linux
  • Plesk 12.0 for Linux

Symptoms

While attempting to connect remotely to MYSQL under admin user the error appears:

Access Denied: Cannot connect to example.com as admin user.

or

# mysql -uadmin -p<admin_password> -P3306 -h<remote_IP>
ERROR 1045 (28000): Access denied for user 'admin'@'<local_IP>' (using password: YES)

Cause

Due to security reasons only local connections are allowed for admin user as default.

Resolution

NOTE: It is strongly recommended to use a particular database user and not admin in order to access a databases remotely.

Yet remote access for admin user can be enabled as follows:

  1. Create dump of mysql database:

    # MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysqldump -u admin mysql > mysql`date +%F_%H.%M`.sql
  2. Connect to mysql database locally:

    #  MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -u admin mysql
  3. Update mysql.user table:

    mysql> update user set Host='%' where User = 'admin';
Have more questions? Submit a request
Please sign in to leave a comment.