I'm deploying a Drupal 7x site to a Digital Ocean Ubuntu 16.04 server for testing and demo purposes. I'm switched the server php versions from php7 to PHP 5.6, but otherwise using the default versions of Mysql and Apache2. I had no problem installing the site and the site functions; however, I frequently have database related errors, specifically, the following one:
PDOException: SQLSTATE[HY000] [2002] Connection refused in lock_may_be_available() (line 167 of /var/www/html/phisigmarho.org/includes/lock.inc).
I typically get that error, but I also get "the website experienced an error" errors or "mysql server has gone away" when I to do anything database or process intensive (updating modules through the UI, etc). I'm relatively new server administration, so I'm not sure what could be wrong or which logs I should be looking at for clues to what's wrong. For the moment, restarting MySQL from the terminal is letting me move forward with setting up the site, but I can't let anyone use the site the way that it is now.
So, how do I figure out why MySQL keeps going away? I'm perplexed, because the server is very similarly configured to my dev machine (ubunutu 16 desktop running php5.6) and I don't have anything remotely similar going on. Where do I look for meaningful logs that will help me diagnose of fix this. So, ideas?
Here are a few things I would try in this scenario.
Install Drush (if not already). Then see what you get for the following commands:
drush status
- check the site configuration looks correct including the DB connectiondrush sqlc
- this will log you into the MySQL command line using the connection details specified in settings.php. It's worth making sure this connection opens successfullydrush cc all
- Clearing your site's caches is always a good idea when migrating to a new environment.If still not working, I would truncate all the cache_* tables in the Drupal database. I have seen errors similar to above and the normal cache clear wasn't enough to resolve it.
Make sure Drupal Watchdog is enabled. drush en dblog
. You can then view watchdog log entries using Drush e.g. drush ws
Check PHP logs. You may need to contact Digital Ocean for location and access to these.