Plesk

RoundCube webmail is not accessible on Plesk: DATABASE ERROR: CONNECTION FAILED

Symptoms

Cause

MySQL roundcube user is either absent or has an invalid password or has not sufficient permissions.

Resolution

Using Plesk interface

  1. Log into Plesk.

  2. Go to Tools & Settings > Updates.

  3. 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.

  1. Connect to the server via SSH.

  2. Create Plesk database backup, for example:

    # plesk db dump > backup.sql

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

  4. Copy the password;

  5. Enter Plesk database:

    # plesk db

  6. 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.

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

  8. 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>');

  9. 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;

Exit mobile version