I recently received an AWS Abuse report on one of my client’s AWS LightSail instances. Nothing was found on the detailed investigation, seemingly a false alarm. However, just to be on the safer side, I migrated the app to a new Lightsail instance.
After which, I was surprised to get a MySQL ERROR 2002 (HY000): Can’t connect to local MySQL server through socket error while testing the app post a successful migration!
I thought that somehow, the MySQL daemon had failed to start. Being on an Amazon Bitnami LAMP stack on lightsail, I tried the following:
sudo opt/bitnami/ctlscript.sh restart
The command ran successfully but to my surprise, I still got the MySQL ERROR 2002 (HY000): Can’t connect to local MySQL server through socket error!
I then tried to first stop the process (apache, MySQL, and Php) and then start them again.
In order to do that, I did the following:
sudo opt/bitnami/ctlscript.sh stop
followed by:
sudo opt/bitnami/ctlscript.sh start
I was surprised that it did not work on the first attempt itself when I tried restarting the MySql server.
The point here being, sometimes a restart doesn’t work you have to stop and then start a process in order to make it work!
1 thought on “[SOLVED] MySQL ERROR 2002 (HY000): Can’t connect to local MySQL server through socket On Amazon Lightsail”
Pingback: How To Create Daily Automated Backups on an Amazon Lightsail Instance? - Rajiv Verma