I was out of balance with my payments and after the payment made it still shows "Error...

Posted July 5, 2016 2.2k views
WordPressBillingUbuntu 16.04

I was out of balance with my server payments and after the payment it still shows “Error establishing a database connection” and I cannot access my website.
How to restart the server or whats wrong.
Restarting Apache and mysql did not help.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

This error generally indicates that your MySQL service is not responding. If no changes were made to WordPress’ wp-config.php then the MySQL service is the place to start.

You mentioned already trying to restart MySQL, this can be done with the command:

service mysql restart

If you continue to see the error message, I would then recommend checking the files in /var/log/mysql/ as there is likely an error recorded there. If you can share any error message you find there with us we can figure out the next step.

  • I made changes in wp-config.php before but I edit the changes back because it did not work right now. I tried to change the domain settings.

    service mysql restart - not working. Only sudo command is working.

    If I try to access /var/log/mysql/ then messages appears:
    Error: Directory /var/log/mysql: permission denied
    Error: Failed to retrieve directory listing

  • I was able to accès log files from FileZilla.
    I used Terminal and command sudo cat /var/log/syslog to access the file.

    Jul  6 07:04:19 wordpress-1gb-ams3 /etc/mysql/debian-start[24583]: Upgrading MySQL tables if necessary.
    Jul  6 07:04:19 wordpress-1gb-ams3 /etc/mysql/debian-start[24586]: /usr/bin/mysql_upgrade: the '--basedir' option is always ignored
    Jul  6 07:04:19 wordpress-1gb-ams3 /etc/mysql/debian-start[24586]: Looking for 'mysql' as: /usr/bin/mysql
    Jul  6 07:04:19 wordpress-1gb-ams3 /etc/mysql/debian-start[24586]: Looking for 'mysqlcheck' as: /usr/bin/mysqlcheck
    Jul  6 07:04:19 wordpress-1gb-ams3 /etc/mysql/debian-start[24586]: This installation of MySQL is already upgraded to 5.5.49, use --force if you still need to run mysql_upgrade
    Jul  6 07:04:19 wordpress-1gb-ams3 /etc/mysql/debian-start[24597]: Checking for insecure root accounts.
    Jul  6 07:04:19 wordpress-1gb-ams3 /etc/mysql/debian-start[24602]: WARNING: mysql.user contains 3 root accounts without password!
    Jul  6 07:04:19 wordpress-1gb-ams3 /etc/mysql/debian-start[24603]: Triggering myisam-recover for all MyISAM tables
    Jul  6 07:09:01 wordpress-1gb-ams3 CRON[24804]: (root) CMD (  [ -x /usr/lib/php5/sessionclean ] && /usr/lib/php5/sessionclean)
    Jul  6 07:17:01 wordpress-1gb-ams3 CRON[24846]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
    Jul  6 07:39:01 wordpress-1gb-ams3 CRON[25117]: (root) CMD (  [ -x /usr/lib/php5/sessionclean ] && /usr/lib/php5/sessionclean)
    Jul  6 08:09:01 wordpress-1gb-ams3 CRON[25569]: (root) CMD (  [ -x /usr/lib/php5/sessionclean ] && /usr/lib/php5/sessionclean)
    Jul  6 08:17:01 wordpress-1gb-ams3 CRON[25683]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
  • I got mysql error also

    sudo cat /var/log/mysql/error.log
    160706  7:04:15 [Note] /usr/sbin/mysqld: Normal shutdown
    160706  7:04:15 [Note] Event Scheduler: Purging the queue. 0 events
    160706  7:04:15  InnoDB: Starting shutdown...
    160706  7:04:17  InnoDB: Shutdown completed; log sequence number 59577283
    160706  7:04:17 [Note] /usr/sbin/mysqld: Shutdown complete
    160706  7:04:17 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead.
    160706  7:04:17 [Note] Plugin 'FEDERATED' is disabled.
    160706  7:04:17 InnoDB: The InnoDB memory heap is disabled
    160706  7:04:17 InnoDB: Mutexes and rw_locks use GCC atomic builtins
    160706  7:04:17 InnoDB: Compressed tables use zlib 1.2.8
    160706  7:04:17 InnoDB: Using Linux native AIO
    160706  7:04:17 InnoDB: Initializing buffer pool, size = 128.0M
    160706  7:04:17 InnoDB: Completed initialization of buffer pool
    160706  7:04:17 InnoDB: highest supported file format is Barracuda.
    160706  7:04:17  InnoDB: Waiting for the background threads to start
    160706  7:04:18 InnoDB: 5.5.49 started; log sequence number 59577283
    160706  7:04:18 [Note] Server hostname (bind-address): ''; port: 3306
    160706  7:04:18 [Note]   - '' resolves to '';
    160706  7:04:18 [Note] Server socket created on IP: ''.
    160706  7:04:18 [Note] Event Scheduler: Loaded 0 events
    160706  7:04:18 [Note] /usr/sbin/mysqld: ready for connections.
    Version: '5.5.49-0ubuntu0.14.04.1'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  (Ubuntu)

Hello, all

I will recommend you to check our article on How To Debug the WordPress Error Establishing Database Connection:

This crash is most likely due to your system running out of memory. I’d suggest that you add a swap file to give yourself a bit more of a buffer. Check out this tutorial:

How To Add Swap on Ubuntu

You will most definitely need to upgrade your droplet as you’re running out of memory and your application/website needs more resources in order to continue to operate.

What you can also do is to use the MySQLTuner script.

The MySQLTuner is a script written in Perl and allows you to quickly test your MySQL configuration and it gives you suggestions for adjustments to increase performance and stability.

According to the official GitHub page, it supports 300 indicators for MySQL/MariaDB/Percona Server in this last version.

To run the script you could do the following:

  • SSH to your Droplet
  • Download the script:
wget -O
  • Then execute it:

The script would run multiple checks against your MySQL instance, all checks done by MySQLTuner are documented here.

Also as stated in the official documentation, it is still extremely important for you to fully understand each change you make to a MySQL database server. If you don’t understand portions of the script’s output, or if you don’t understand the recommendations, you should consult a knowledgeable DBA or system administrator that you trust.

As a good practice make sure to always test your changes on staging environments before implementing them on your production database.

On the same note, if you want to have a worry-free MySQL hosting and focus on your application, I would recommend trying out the DigitalOcean Managed Databases:

This was mini tutorial was posted from bobbyiliev in this question in our community:

You can also create a simple bash script to check if MySQL is running and if not to restart it.


# Check if MySQL is running
sudo service mysql status > /dev/null 2>&1

# Restart the MySQL service if it's not running.
if [ $? != 0 ]; then
    sudo service mysql restart

Run this script every 5 minutes using a cron job like this one:

 */5 * * * * /home/user/scripts/ > /dev/null 2>&1

Hope that this helps!

by Brian Boucheron
WordPress is one of the most popular open source content management systems in the world. Although it started out focused on blogging, over the years it has developed into a more flexible platform for websites in general. After almost fifteen years of development it is quite polished and robust, yet issues can still come up. If you've recently attempted to load your WordPress-powered website and instead saw a message stating "Error Establishing Database Connection", the cause is most often...