Symptoms
-
RoundCube webmail page is not accessible. The following error message is displayed:
DATABASE ERROR: CONNECTION FAILED
DB Error: SQLSTATE[28000] [1045] Access denied for user 'roundcube'@'localhost' (using password: YES) (GET /roundcube/index.php)
DATABASE ERROR: CONNECTION FAILED! Unable to connect to the database! Please contact your server administrator.
Cause
MySQL roundcube
user is either absent or has an invalid password or has not sufficient permissions.
Resolution
Using Plesk interface
-
Log into Plesk.
-
Go to Tools & Settings > Updates.
-
Remove the component
Roundcube
and then install it again.
Using SSH connection
Note: The solution may be a bit complex. Contact server's administrator or hosting support if required.
-
Connect to the server via SSH.
-
Create Plesk database backup, for example:
# plesk db dump > backup.sql
-
Depending on the RoundCube version, check the database password in
/usr/share/psa-roundcube/config/config.inc.php
or/usr/share/psa-roundcube/config/db.inc.php
:# cat /usr/share/psa-roundcube/config/config.inc.php
$config['db_dsnw'] = 'mysqli://roundcube:password@localhost/roundcubemail'; -
Copy the password;
-
Enter Plesk database:
# plesk db
-
Make sure that 'roundcubemail' database exists:
mysql> show databases like "%roundcube%";
+------------------------+
| Database (%roundcube%) |
+------------------------+
| roundcubemail |
+------------------------+
1 row in set (0.00 sec)If the database is missing, go back to the first solution via Plesk user interface and reinstall (remove/install) RoundCube component. If the database is present continue this guide.
-
Check whether the
roundcube
user is present. Empty output means that the user is absent:mysql> use mysql;
mysql> select * from user where user='roundcube'; -
Create user and assign a password:
Note: If the user exists already, it is only needed to generate the password. There is no need for the CREATE USER sentence
For MySQL 5.0/5.1/5.5/5.6 and MariaDB 10.1
mysql> CREATE USER 'roundcube'@'localhost';
mysql> update user set password=password('<password_from_config.inc.php>') where user ='roundcube';For MySQL 5.7
mysql> CREATE USER 'roundcube'@'localhost';
mysql> SET PASSWORD FOR 'roundcube'@'localhost' = '<password_from_config.inc.php>';For MariaDB 10.5+
MariaDB [mysql]> CREATE USER 'roundcube'@'localhost';
MariaDB [mysql]> SET PASSWORD FOR 'roundcube'@'localhost' = PASSWORD('<password_from_config.inc.php>'); -
Grant the necessary privileges:
mysql> GRANT USAGE ON roundcubemail.* TO 'roundcube'@'localhost';
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON roundcubemail.* TO 'roundcube'@'localhost';
mysql> flush privileges;Note: if "Can't find any matching row in the user table" error appears when running Grant command, use command without the host:
mysql> GRANT USAGE ON roundcubemail.* TO 'roundcube';
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON roundcubemail.* TO 'roundcube';
mysql> flush privileges;