ssuhat
ssuhat

Reputation: 7656

`ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2 "No such file or directory")`

I've recently upgrade my homestead to latest release (Ubuntu 16.04) and reinitialize all homestead.yaml, etc.

I've put: mariadb: true inside Homestead.yaml. Everything installed perfectly and running normally. But after sometime mysql will stop by itself.

Error:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2 "No such file or directory")

I've tried sudo services mysql reload. its working back to normal but start shutting down after few minutes.

Before upgrading everything is working perfectly.

Any suggestion? I've tried re-provision still no hope.

Upvotes: 1

Views: 2896

Answers (2)

ssuhat
ssuhat

Reputation: 7656

apparmor was the culprit. Despite the contents of /etc/apparmor.d/usr.sbin.mysqld being nothing but comments and claiming that it was there so that apparmor wouldn't choke on MariaDB, that's exactly what was happening.

AppArmor and MySQL on an Oracle blog provided what I needed to figure out what was going on.

sudo aa-status shows you what apparmor is doing; what actually has an enforced policy, versus what's just set to complain.

sudo apt-get install apparmor-utils adds a few commands that make the apparmor profiles easier to deal with, such as...

sudo aa-complain /usr/sbin/mysqld turns the profile from "enforce" to complain. (aa-enforce turns it back.)

Once that's done, sudo service apparmor reload restarts apparmor, and voila... sudo /etc/init.d/mysql start works, and the server stays up.

Reference: https://askubuntu.com/questions/750604/why-does-mariadb-keep-dying-how-do-i-stop-it

Upvotes: 0

Utwo
Utwo

Reputation: 401

I had a similar issue. Try installing virtualbox version 5.0.18 https://www.virtualbox.org/wiki/Download_Old_Builds_5_0 and then run

vagrant reload --provision

Upvotes: 1

Related Questions