Articles in this section

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

Plesk for Linux kb: technical ABT: Group B

Applicable to:

  • Plesk for Linux 

Symptoms

  • RoundCube webmail page is not accessible. The following error message is displayed:

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


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

  • The same error may be shown in the log file /var/log/plesk-roundcube/errors

  • The following MySQL request shows the empty output:

    MYSQL_LIN: mysql> select * from mysql.user where user='roundcube';

  • The following error occurs in a log /var/log/plesk/install/autoinstaller3.log during a Plesk upgrade:

    CONFIG_TEXT: Trying to upgrade Roundcube Web Based mail client configs and DB from '1.2.7' to '1.3.6'... Executing database schema update.
    ERROR: SQLSTATE[28000] [1045] Access denied for user 'roundcube'@'localhost' (using password: NO)
    Error 500: Error connecting to database: SQLSTATE[28000] [1045] Access denied for user 'roundcube'@'localhost' (using password: NO)

Cause

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

Resolution

Click on a section to expand

Using Plesk interface
  1. Log into Plesk.

  2. Go to Tools & Settings > Updates.

    000027.JPG

  3. Remove the component Roundcube and then install it again.

    000028.JPG


    000026.JPG

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_LIN: 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_LIN: 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_LIN: mysql> CREATE USER 'roundcube'@'localhost';
    mysql> update user set password=password('<password_from_config.inc.php>') where user ='roundcube';

    For MySQL 5.7

    MYSQL_LIN: mysql> CREATE USER 'roundcube'@'localhost';
    mysql> SET PASSWORD FOR 'roundcube'@'localhost' = '<password_from_config.inc.php>';

    For MariaDB 10.5+

    MYSQL_LIN: MariaDB [mysql]> CREATE USER 'roundcube'@'localhost';
    MariaDB [mysql]> SET PASSWORD FOR 'roundcube'@'localhost' = PASSWORD('<password_from_config.inc.php>');

    If the ERROR 1372 (HY000): Password hash should be a 41-digit hexadecimal number error occurs while trying to set the password for the roundcube user, it's needed to first encrypt the password obtained on step 3 with: select password('<password_from_config.inc.php>');, then use this output which is hexa and 41 long to set the password on step 8.

  9. Grant the necessary privileges:

    MYSQL_LIN: 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_LIN: mysql> GRANT USAGE ON roundcubemail.* TO 'roundcube';
    mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON roundcubemail.* TO 'roundcube';
    mysql> flush privileges;

Was this article helpful?

Comments

1 comment
Date Votes
  • Hi!

    After installing Plesk 2 weeks ago and now using Plesk Migrator, I was not able to use Roundcube Webmail.

    Futher investigations showed, that the database was not create on installation:

    DB Error: SQLSTATE[HY000] [1049] Unknown database 'roundcubemail' in /usr/share/psa-roundcube/program/lib/Roundcube/rcube_db.php on line 201 (GET /)

    Unfortunately, reinstalling Roundcube using the Plesk updater did not work. It did not create the Plesk DB. 
    I had a look at the Roundcube documentation and was able to figure out a fix:

    plesk db:

    CREATE DATABASE roundcubemail CHARACTER SET utf8 COLLATE utf8_general_ci;

    then

    mysql roundcubemail < /usr/share/psa-roundcube/SQL/mysql.initial.sql

     

     

     

    0

Please sign in to leave a comment.