×


Plesk Roundcube 'database error connection failed' - Fix it Now ?

Sometimes, while trying to access the RoundCube webmail page it will turn out to be inaccessible displaying 'database error connection failed'  error.

Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to resolve related Roundcube errors.

In this context, we shall look into how to fix this database error.


Nature of Plesk Roundcube 'database error connection failed' error ?

When the RoundCube webmail page is not accessible we may get either of the following error messages:

DATABASE ERROR: CONNECTION FAILED DB Error: SQLSTATE[28000] [1045] Access denied for user ’roundcube’@’localhost’ (using password: YES) (GET /roundcube/index.php)

or

DATABASE ERROR: CONNECTION FAILED! Unable to connect to the database! Please contact your server-administrator.

The main causes of this error includes:

  • MySQL Roundcube user is absent.
  • The Roundcube user has an invalid password.
  • Insufficient permissions.


How to fix Plesk Roundcube 'database error connection failed' error ?

1. Using Plesk interface

Following are the steps:

i. First, we have to log in to Plesk.

ii. Then go to Tools & Settings and take Updates.

iii. Now we can remove the component Roundcube and then install it again.


2. Using SSH connection

Next, we can see how to fix this error via SSH. However, the solution may be a bit complex.

i. Firstly, we have to connect to the server via SSH.

ii. And create Plesk database backup. For this we can use the following command:

# plesk db dump > backup.sql

iii. After that, depending on the RoundCube version. Furthermore, we have to check the database password in /usr/share/psa-roundcube/config/config.inc.php or /usr/share/psa-roundcube/config/db.inc.php using the following command:

# cat /usr/share/psa-roundcube/config/config.inc.php
$config['db_dsnw'] = 'mysqli://roundcube:password@localhost/roundcubemail';

iv. Now copy the password and enter the Plesk database using the following command:

# plesk db

v. After that we can ensure that 'roundcubemail' database exists:

ysql> show databa<"%roundcube%";
+------------------------+
| Database (%roundcube%) |
+------------------------+
| roundcubemail          |
+------------------------+
1 row in set (0.00 sec)

If we find the database missing, we must go to the first solution via the Plesk user interface and reinstall (remove/install) the RoundCube component. In case the database is present we can go to the next step.

vi. Next, we must check whether the roundcube user is present. (Empty output means that the user is absent.)

We can use the following commands to check this:

mysql> use mysql;
mysql> select * from user where user='roundcube';

vii.  After that we have to create the user and assign a password (no need to create a user if already exists, simply generate the password).

We can use the following commands for this:

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>';

viii. Then we have to grant the necessary privileges using the following command:

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;

If we get "Can’t find any matching row in the user table" error while running the Grant command,  we can use the following 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;


[Need assistance in fixing Plesk errors? We can help you. ]


Conclusion

This article covers methods to fix Plesk Roundcube 'database error connection failed' for our customers. This error happens when MySQL roundcube user is either absent or have an invalid password or have not sufficient permissions.