Access denied for mysql user while installing application

Created:

2016-11-16 12:44:36 UTC

Modified:

2017-08-08 13:30:26 UTC

0

Was this article helpful?


Have more questions?

Submit a request

Access denied for mysql user while installing application

Applicable to:

  • Plesk for Windows

Symptoms

  • While installing a new APS application in Plesk , one of the following error messages appeared:

    `Error: Installation of WordPress at http://domain.tld/wordpress failed. Non-zero exit status returned by script. Output stream: 'PHP Warning: mysql_connect(): Access denied for user 'wordpress_1'@'localhost' (using password:  <Password has been wiped out for security reasons>`

    `Error: Installation of WordPress at http://domain.tld/wordpress failed. Non-zero exit status returned by script. Output stream: 'Unable to connect to DB: Access denied for user 'wordpress_1'@'localhost' (using password: YES) PHP Warning: mysql_connect(): Access denied for user 'wordpress_1'@'localhost' (using password: YES) in C:\\Program Files (x86)\\Parallels\\Plesk\\var\\apspackages\\aps8BDB.tmp.zip83b3f87b-a502-cbd9-d2\\cache\\scripts\\db-util.php on line 66 (Error code 1)'.`

    `Error stream: 'Unable to connect to DB: Access denied for user 'wordpress_1_'@'localhost' (using password: YES) PHP Warning: mysql_connect(): Access denied for user 'wordpress_1'@'localhost' (using password: YES) in C:\\Program Files (x86)\\Parallels\\Plesk\\var\\apspackages\\aps8BDB.tmp.zip83b3f87b-a502-cbd9-d2\\cache\\scripts\\db-util.php on line 66 (Error code 1)'.`
  • Execution of this query gives non-empty output:

    mysql> select user,host,password from mysql.user where user='' and host='localhost';

Cause

  1. Two MySQL database servers are configured on the same port.

  2. Empty user name in 'mysql.user' table. User with empty name should not persist in table.

    In general Plesk creates MySQL database users with host='%' . This wildcard allows connect to MySQL database with user from any host. The reason that this does not work is that the default privileges include an entry with host='localhost' and User='' (empty username). Because that entry has a Host value 'localhost' that is more specific than '%' , it is used in preference to the new entry when connecting from localhost.

Resolution

  1. Make sure that only one MySQL server is listening on 3306 port.

  2. Remove a record with an empty username from a MySQL database on 3306 port:

    mysql> delete from mysql.user where user='' and host='localhost';
    mysql> flush privileges;
  3. Make sure that you can authenticate with existing MySQL user:

     "%plesk_dir%mysql\\bin\\mysql" -u<mysql-user> -p<user_password>
  4. Install the required application.

Have more questions? Submit a request
Please sign in to leave a comment.