database error for horde and roundecube

Sometimes you may face the following errors in webmail.

horde : A fatal error has occurredDB Error: connect failed

roundcube: DATABASE ERROR: CONNECTION FAILED!Unable to connect to the database!

Most probably, its an issue with the databases associated with horde and roundcube, so please check related error logs by

# vi /var/cpanel/horde/log/horde_0.log

Press Shift+G and check the error at bottom.

Feb 27 03:16:06 HORDE [emergency] [horde] DB Error: connect failed:  [nativecode=Access denied for user ‘horde’@’localhost’ (using password: YES)] ** mysql(mysql)://horde:[email protected]+localhost:3306/horde?persistent=1&charset=utf-8&ssl=1&splitread= [pid 18142 on line 398 of “/usr/local/cpanel/base/horde/lib/Horde/Perms/sql.php”]

# vi /var/cpanel/roundcube/log/errors

Press Shift+G and check the error at bottom.

[27-Feb-2012 03:15:09 +0000]: DB Error: _doConnect: [Error message: Access denied for user ’roundcube’@’localhost’ (using password: YES)]
[Native code: 1045]
[Native message: Access denied for user ’roundcube’@’localhost’ (using password: YES)]
** mysql(mysql)://roundcube:[email protected]/roundcube in /usr/local/cpanel/base/3rdparty/roundcube/program/include/rcube_mdb2.php on line 102 (GET /cpsess7853727673/3rdparty/roundcube/index.php)

The issue can be resolved by forced update

# /usr/local/cpanel/bin/update-horde –force
# /usr/local/cpanel/bin/update-roundcube –force

Once update completed, check the webmail.

You are done!

How to install/upgrade roundcube in a cPanel/Linux server

Before installing roundcube on a cPanel server you should know your mysql root password. Replace DATABASEPASSWORD with your mysql root password.

If Roundcube is already installed, you need to uninstall it.

Uninstall/remove exiting RoundCube

# cd /usr/local/cpanel/base

# rm -rf roundcube*

On mysql prompt

mysql -e ‘drop database roundcube’;

# /scripts/upcp

Now follow the  steps to update/install latest roundcube. You will have to specify your root password when prompted.

# cd /usr/local/cpanel/base

# wget -O roundcube.tar.gz http://nchc.dl.sourceforge.net/sourceforge/

# roundcubemail/roundcubemail-0.2.1.tar.gz

# rm -rf roundcube.tar.gz

# mv -f roundcubemail-0.2.1/ roundcube

# cd roundcube

# chmod -R 777 temp

# chmod -R 777 logs

Database Configuration

Create the database, database user and install the intial sql file. The following commands will do this for you.

mysql -e “CREATE DATABASE roundcube;”

mysql -e “GRANT ALL PRIVILEGES ON roundcube.* TO [email protected] IDENTIFIED BY

‘DATABASEPASSWORD’;”

mysql -e “FLUSH PRIVILEGES;”

mysql -e “use roundcube; source SQL/mysql.initial.sql;”

You will have to replace the roundcube password with ‘DATABASEPASSWORD’ field.

Roundcube Configuration

# cd config

# mv db.inc.php.dist db.inc.php

# mv main.inc.php.dist main.inc.php

then open database configruation file db.inc.php in your favroite editor.

# vi db.inc.php

Find following line

$rcmail_config[‘db_dsnw’] = ‘mysql://roundcube:[email protected]/roundcubemail’;

Replace it with

$rcmail_config[‘db_dsnw’] = ‘mysql://roundcube:[email protected]/roundcube’;

Now Open main.inc.php

# vi main.inc.php

Find

$rcmail_config[‘default_host’] = ”;

Replace with

$rcmail_config[‘default_host’] = ‘localhost’;

Configure cPanel to show roundcube in the theme. Please note this is for the X theme(default) only!! If you use another theme please skip the next part and see below.

# cd /usr/local/cpanel/base/roundcube/skins/default/images/

# cp –reply=yes roundcube_logo.png /usr/local/cpanel/base/frontend/x/images/roundcube_logo.png

# cp –reply=yes roundcube_logo.png /usr/local/cpanel/base/webmail/x/images/roundcube_logo.png

# cd /usr/local/cpanel/base

# wget http://www.solsearch.net/HGpatch-roundcube-1.0BETA2

# patch -p0 < HGpatch-roundcube-1.0BETA2

# chattr +i /usr/local/cpanel/base/frontend/x3/webmaillogin.html

# chattr +i /usr/local/cpanel/base/webmaillogin.cgi

Restart the mysql, cpanel services on your server. You are done!, have fun with your new Roundcube installation!!

You can access roundcube by http://yourdomain.com/webmail.