A frequently occurred problem that makes your Drupal or other CMS fail is:
PDOException: SQLSTATE[HY000]  Can't connect to local MySQL server through socket
'/var/run/mysqld/mysqld.sock' (111) in lock_may_be_available() (line 167 of /var/www/drupal
I saw many people asking this problem online, but did not see any viable answers. After Googling for hours, I finally came up with a solution. Let me start with what causes this problem.
Why this problem happens?
How to solve this issue?
- Login into your instance from Terminal or Command Prompt via SSH.
- Now, switch to Root mode (Sudo su)
- Run the following command: dd if=/dev/zero of=/swapfile bs=1M count=1024
- Make a swap file by running: mkswap /swapfile
- Turn on Swap Files: swapon /swapfile