Showing Database Error CONNECTION FAILED under webmail

Almost all the technical aspects that possess different functionalities on the server are fed with the database wherein the useful transmission of the data takes place. When the server fails to connect to the database there arrives the possible error called database error connection failed. This is true even with the web mail. How to deal with the same is elaborated below.


What is the Issue?

While visiting this URL For example http://100.00.00.123/etc/app/webmail under HostingRaja VPS or Cloud server it is  showing database error CONNECTION FAILED!.


You need to make sure that your server status is active or not and also the database status  then please proceed to next step which we have mentioned below.


database-error

Why has this issue occurred?

The issue is due to database named  sentora_roundcube and table named vacation under sentora_postfix database  has been corrupted. These 2 databases are related to the HostingRaja

Mail server. Database Corruption will be due to following Reasons:
a) Improper shutdown of mysql server due to power outage.
b) Using “killall -9 mysqld” command to shutdown the server and killing all the ongoing mysql processess.
c) Mysqld Services got stopped due to high load in the server or RAM usage exceeded its limit.
d) Having large amount of data’s in your database.You should make sure that there is enough disk space to store the data in advance.



database-error


How can we prevent it?

Steps to be followed to resolve this kind of issue:


1. Checking error log is a good practice which will resolve your problem very quickly.You will get  the root cause of the issue by using the command:

tail -f /var/sentora/logs/roundcube/errors


2.Now check whether the database is corrupted or not using the command:

mysqlcheck --databases sentora_roundcube


mysqlcheck --databases sentora_postfix


3. If you found database is corrupted check for the available backup of a particular database and download it to your local system:


Database backup will be available under the path:

/backup/mysql/127.0.0.1/sentora_postfix/

/backup/mysql/127.0.0.1/sentora_roundcube/


Enter this command in your local terminal to download the backup,

Example:

rsync -avzhe ssh --progress This email address is being protected from spambots. You need JavaScript enabled to view it.:/root/alldb.sql  /home/comp1/Desktop/


while deleting the table if you get this error:  MySQL Cannot drop index needed in a foreign key constraint.

means you need to drop the primary table of which foreign key is present in the table.

Ex: If the primary table is users, which is having a foreign key in the cache table first you need to drop users table and create users table(Create table details of the particular table is found on downloaded file). Then you need to drop the cache table.This process needs to be followed wherever you get this kind of error.


5. Once database related things is completed/finished you need to check for postfix, roundcube, mysql root, proftpd passwords are working fine or not using the below commands:


cat passwords.txt


mysql -u proftpd -p


mysql -u roundcube -p


mysql -u postfix -p


If it is not working then you need to update latest passwords.The password details will be sent to your registered email ID while your account got created or else you can contact our support team for the same.


6. Next, you need to go the below path:

cd /etc/sentora/configs/postfix/

ls -ll

check for the password present inside this files is correct or not.

mysql-relay_domains_maps.cf

mysql-virtual_alias_maps.cf

mysql-virtual_domains_maps.cf

mysql-virtual_mailbox_limit_maps.cf

mysql-virtual_mailbox_maps.cf

vacation.conf


if the wrong password is present kindly update the new password.


7. Restart httpd, varnish, postfix, dovecot, spamassassin using command,

service httpd restart

service varnish restart

service postfix restart

service dovecot restart

service spamassassin restart


Once you done with it it you will be able to login to webmail account and send emails to the recipients.


The following details help you to save your database corruption on the HostingRaja VPS or Cloud Server:


  1. Take the backup of mysql databases on daily basis along with checking the mysql status.

  2. Don't maintain more load on the server by uploading unwanted files and folders, plugins installation and so on. Build your site quite simple and lightweight with out any fatal code level error.

  3. Don’t do complex queries executions and never maintain large data’s in the database. Optimize mysql queries and build proper table structure.

  4. Its very important that never delete or edit any files or folder in HostingRaja Server without knowing its purpose.


Almost all the technical aspects that possess different functionalities on the server are fed with the database wherein the useful transmission of the data takes place. When the server fails to connect to the database there arrives the possible error called database error connection failed. This is true even with the web mail. How to deal with the same is elaborated below.