Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mysql can't connect to local server through socket on Amazon EC2

I opened my application (in Rails) on Amazon EC2 and got an error - thus I checked the logs and there is following:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111)

10 hours ago was everything working yet. What's the problem? A lot of traffic? The app is running on Micro Instance.

How to fix this issue and how to avoid it in the future?

Thank you very much

EDIT:

sudo find / -type s
---
/tmp/.sock
/dev/log
/var/lib/apt-xapian-index/update-socket
/run/mysqld/mysqld.sock
/run/acpid.socket
/run/dbus/system_bus_socket
/run/udev/control
find: `/proc/4739/task/4739/fd/5': No such file or directory
find: `/proc/4739/task/4739/fdinfo/5': No such file or directory
find: `/proc/4739/fd/5': No such file or directory
find: `/proc/4739/fdinfo/5': No such file or directory
like image 420
user984621 Avatar asked Oct 29 '13 08:10

user984621


People also ask

Can't connect to local MySQL server through socket Mysqldump?

Another possible solution to the >can't connect to local mysql server through socket> error message is to try and connect to the MySQL using the 127.0. 0.1 ip address instead of localhost. When you use localhost to connect to MySQL, the operating system uses the socket connector. However, if you use 127.0.

Why is my EC2 instance not connecting?

The following are common reasons why EC2 Instance Connect might not work as expected: EC2 Instance Connect doesn't support the OS distribution. The EC2 Instance Connect package isn't installed on the instance. There are missing or incorrect AWS Identity and Access Management (IAM) policies or permissions.


1 Answers

In my case, the server had apparently restarted at some point, and mysql was not started when it did. I simply typed the command to start and it worked:

sudo service mysqld start
like image 137
Noah Dyer Avatar answered Sep 26 '22 00:09

Noah Dyer