The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Database error: Connection failed!

Discussion in 'Database Discussions' started by nhacker, Apr 26, 2014.

  1. nhacker

    nhacker Member

    Joined:
    Mar 21, 2014
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Hello,

    Every thing is ok except roundcube could you please provide us the solution.

    DATABASE ERROR: CONNECTION FAILED!

    Unable to connect to the database!
    Please contact your server-administrator.

    Thank you
     
  2. hostkingco

    hostkingco Member

    Joined:
    Apr 25, 2014
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    US
    cPanel Access Level:
    DataCenter Provider
    Have you tried forcing a reinstall? upcp --force
    Seems to fix most of the issues we've ever encountered with Cpanel over the years. Works almost everytime
     
  3. cPanelPeter

    cPanelPeter Technical Analyst III
    Staff Member

    Joined:
    Sep 23, 2013
    Messages:
    569
    Likes Received:
    15
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello,

    Do you see any errors in /usr/local/cpanel/logs/error_log or /var/lib/mysql/hostname.err ?
    (replace hostname with your actual hostname).
     
  4. panayot

    panayot Well-Known Member

    Joined:
    Nov 18, 2004
    Messages:
    125
    Likes Received:
    0
    Trophy Points:
    16
    Hello, I had the same error message from Roundcube.

    SOLUTION:

    In my case the error was caused by moving an account from a very old cpanel server to a new one. (Both servers use sqlite databases for roundcube user settings)

    On RHEL 4 the version of sqlite is sqlite2 and on RHEL 6 it is sqlite3. sqlite3 cannot read the format of sqlite2 databases which causes the error.

    On this page it is described how to convert between formats: SQLite Version 3 Overview

    Code:
    sqlite OLD.DB .dump | sqlite3 NEW.DB
    I wrote a script sqlite2to3.sh that takes account name as the argument and converts all sqlite2 Roundcube databases. It will not convert the databases if it is already in version 3 format.

    On Centos 6 the version 2 sqlite was missing so I installed it from here: sqlite2-2.8.17-5.el6.remi.x86_64.rpm CentOS 6 Download

    Code:
    #!/bin/bash
    
    if [ ! $# -eq 1 ]
    then
      echo "USAGE: `basename $0` <username>"
      exit
    fi
    
    user=$1
    
    if [ ! -d /home/$user/etc ] ; then
     echo "/home/$user/etc not found!"
     exit
    fi
    
    cd /home/$user/etc
    
    for i in `find . -name '*rcube.db'`; do
     echo "Converting $i"
     sqlite $i .dump > /dev/shm/sqlite2to3-$$
     OUT=$?
     if [ $OUT -eq 0 ]; then
      mv $i $i-oldformat
      sqlite3 $i < /dev/shm/sqlite2to3-$$
      chown $user.mail $i
      chmod 600 $i
     fi
    done
    
    rm -f /dev/shm/sqlite2to3-$$
    Hope it helps someone.
     
    #4 panayot, Jun 9, 2014
    Last edited: Jun 9, 2014
  5. whplus

    whplus Well-Known Member

    Joined:
    Dec 8, 2007
    Messages:
    66
    Likes Received:
    1
    Trophy Points:
    8
    Location:
    Behind your business
    you can try to repair roundcube db
     
  6. iserversupport

    iserversupport Well-Known Member

    Joined:
    Nov 4, 2013
    Messages:
    91
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    India
    cPanel Access Level:
    Root Administrator
    Try the script

    /usr/local/cpanel/bin/update-roundcube --force

    Which will update roundcube
     
  7. SS-Maddy

    SS-Maddy Well-Known Member

    Joined:
    Mar 28, 2009
    Messages:
    83
    Likes Received:
    0
    Trophy Points:
    6
    cPanel Access Level:
    Root Administrator
    Check whether you are able to connect to the roundcube db using the credentials present in the configuration file /usr/local/cpanel/base/3rdparty/roundcube/config/config.inc.php

    The credentials are given as
    $config['db_dsnw'] = 'mysql://roundcube:<password>@localhost/roundcube';

    If not, try after resetting it. If that too fails proceed with reinstall after taking the db backup
     
  8. Ekon

    Ekon Member

    Joined:
    Oct 29, 2014
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Website Owner
    Hi there,

    This is quite a simple question for any of you to answer but a tough one for me: I have the same problem as the OP posted, so how or where do I input this command? cPanel web address, some file in my computer?

    Consider I'm a newbie in this subject.

    Thanks in advance
     
  9. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,447
    Likes Received:
    195
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    Unless you have root level access to that server, you'll need to contact your Hosting Provider about this. Website owners would not have access to run that command.
     
  10. Ekon

    Ekon Member

    Joined:
    Oct 29, 2014
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Website Owner
    Thanks Infopro.

    I'll contact support.
     
  11. postcd

    postcd Well-Known Member

    Joined:
    Oct 22, 2010
    Messages:
    619
    Likes Received:
    6
    Trophy Points:
    18
    I got same error and what fixed it was editting ****/roundcube/db.inc.php file, i fixed mysql password which was there, but was incomplete. then it started working
     
  12. Ekon

    Ekon Member

    Joined:
    Oct 29, 2014
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Website Owner
    Thanks, where do I find this file?
     
  13. postcd

    postcd Well-Known Member

    Joined:
    Oct 22, 2010
    Messages:
    619
    Likes Received:
    6
    Trophy Points:
    18
    I did this command via linux commandline to find it:
    find / -type f -name "db.inc.php"
     
  14. Ekon

    Ekon Member

    Joined:
    Oct 29, 2014
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Website Owner
    What about windows?

    thanks for the info.
     
  15. postcd

    postcd Well-Known Member

    Joined:
    Oct 22, 2010
    Messages:
    619
    Likes Received:
    6
    Trophy Points:
    18
    im using RoundCube on Linux, maybe Windows has an Search function or manually browse roundcube directories and ensuring you have acurate mysql details there
     
  16. Ekon

    Ekon Member

    Joined:
    Oct 29, 2014
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Website Owner
    Got it. Thanks a lot.

    The thing is, these issues kinda solve themselves regardless of what I try, luckily.
     
Loading...

Share This Page