- Plesk 11.x for Windows
Some domains are returning this error:
Database connection error (2): Could not connect to MySQL
The error means that the some domain's script is trying to connect to a MySQL database, but is failing to do so.
First, find the script and make sure it is using the correct database name and credentials when connecting. For illustration purposes, let us assume that the script is using these credentials:
Log in to the server via SSH and try to connect to the same database manually using the above credentials:
# mysql -h localhost -utestuser -ptest testdb
If the connection fails, make sure that the needed database, user, and password indeed exist on the server. Even if they are shown in the Plesk web interface, check if they exist in MySQL directly.
For example, it may be that the
is missing from the
table. In that case, add the user manually by running these commands in the shell:
# MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -u admin mysql
mysql > GRANT USAGE ON *.* TO 'testuser'@'%' IDENTIFIED BY 'test';
mysql > GRANT ALL PRIVILEGES ON `testdb`.* TO 'testuser'@'%';
mysql > FLUSH PRIVILEGES;``