Mysql无法通过Amazon EC2上的套接字连接到本地服务器

问题描述:

我在Amazon EC2上打开了我的应用程序(在Rails中)并收到错误-因此我检查了日志,并显示以下内容:

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个小时前一切正常.有什么问题?流量大吗? 该应用程序正在Micro Instance上运行.

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?

非常感谢您

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

在我的情况下,服务器显然已在某个时间点重新启动,而mysql在启动时并未启动.我只是键入要启动的命令就可以了:

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