Closed ghost closed 9 years ago
Check if mysql is running, or if it's just service mysql status
that says it's not running.
It looks like connecting through /var/run/mysqld/mysqld.sock
doesn't work, but connecting over a socket connection (e.g. to 127.0.0.1
) does:
vagrant@vagrant:/etc/phpmyadmin$ mysql -uroot -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
vagrant@vagrant:/etc/phpmyadmin$ mysql -uroot -p -h127.0.0.1
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.5.41-0ubuntu0.14.04.1 (Ubuntu)
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> Bye
vagrant@vagrant:/etc/phpmyadmin$
Workaround for phpmyadmin: set $dbserver='127.0.0.1'
in /etc/phpmyadmin/config-db.php
.
It'd would be better if the unix socket worked though...
I'm out of the house at the moment, but will check this above when I return this evening.
I've not yet had a chance to look into why this is happening - most causes of this I can see are when the mysqld.sock cannot be created - leaving permissions or disk space as far as I can tell. df
tells me I've plenty of space, so I'm suspecting permissions on the /var/run/
dir.
So, as mentioned above, MySQL is running, but can't accept connections through the unix socket. The phpmyadmin workaround does work out, but it's now nagging me that the socket isn't working.
A quick grep of the ps ax
output showed the config file MySQL is loading.
1008 ? Ssl 0:01 /usr/sbin/mysqld --defaults-file=/etc/mysql-default/my.cnf
This in turn shows that the socket here is being specified as:
socket = /run/mysql-default/mysqld.sock
which is at odds with the attempted socket connection reported in the above error messages.
After a little while, I forced a connection to the correct socket (/run/mysql-default/mysqld.sock
), et voila.
Symlinking the mysql-default contents into mysqld will allow the system to work as expected, including phpmyadmin via unix socket.
sudo mkdir /var/run/mysqld && sudo ln -s /var/run/mysql-default/* /var/run/mysqld/
I'm now trying to hunt down a 'proper' fix - and, why the MySQL client believes it should be connecting to '/var/run/mysqld/mysqld.sock'
rather than the correct socket specified in the my.cnf file, however I think this runs a little beyond my skillset.
The mysql server looks for /var/run/mysqld/mysqld.sock but the mysql.sock file
find / -name '*.sock' to find the mysql.sock file and then used
ln -s
On a fresh
vagrant up
, I'm struggling to get MySQL running. I'm perhaps overlooking something simple, but thus far have discovered nothing.On trying to start the service, the call fails, and I'm unable to start it by any other method I've tried. There's ample 'disk space' available - which I note is a common cause of this issue, I'm also unable to find the .sock file, so theorise this could be why. I'm no ninja, however - an I'm not too sure how to go about verifying.
Vagrant up below: