8

I have googled for 2 days now and was initially get a

'/var/run/mysqld/mysqld.sock' (2)

I fixed this by using:

sudo touch /var/run/mysqld/mysqld.sock
sudo chown -R mysql /var/run/mysqld/

now i get the error:

 '/var/run/mysqld/mysqld.sock' (13)

So everything has the correct permissions and the file exists. Any thoughts?

[Edit]

Got it working, although i am unsure how. I did aa-logprof as root, nothing changed, got angry and then re-set it started working.

4 Answers 4

6

In my case, running mysqld_safe created a new mysqld.sock file.

$ cd /etc/init.d/
$ mysqld_safe

You'll probably won't get the prompt back, but if you restart your session, a mysqld.sock file will be somewhere. Find it with

$ sudo find / -type s | grep mysqld.sock
1
  • Nice, I got this error (I guess) because I cancelled an alter table of a huge one, I didn't find any lock file but mysqld_safe fixed this! Thanks. Apr 23, 2015 at 0:19
5

You cannot (absolutely cannot) replace the filesystem pipe /var/run/mysqld/mysql.sock with a regular file. You need to use mkfifo(1) to create the pipe(7) that clients use to communicate with the mysql server.

The (13) probably also means that you have a permission denied error return, EACCES (which usually has the decimal value 13 -- yes, I've seen it a lot).

If the file system permissions are configured correctly, you might be having accesses rejected by a mandatory access control tool such as AppArmor, SELinux, TOMOYO, or SMACK.

AppArmor comes pre-installed on Ubuntu systems by default, and might be rejecting access to the pipe. Check /var/log/syslog, /var/log/audit/audit.log or dmesg(1) output for messages that look something like this:

type=AVC msg=audit(1320723925.179:45115): apparmor="DENIED"
operation="open" parent=1 profile="/usr/sbin/ntop"
name="/usr/share/ntop/html/PlotKit/excanvas.js" pid=1835 comm="ntop"
requested_mask="r" denied_mask="r" fsuid=122 ouid=0

(But with name=/var/run/mysqld/mysql.sock instead.)

If you have error messages like this, run aa-logprof as root and answer the questions. More information on configuration AppArmor can be found in the apparmor.d(5) manpage, or some various wiki pages.

12
  • Thanks the great reply. Always wish i spent more time with mysql rather than just queries. So i get this error when i do mysql start "ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111)". Previously i had no problems starting mysql :/ Nov 23, 2011 at 10:55
  • 111104 11:54:40 [Note] Plugin 'FEDERATED' is disabled. 111104 11:54:40 InnoDB: Initializing buffer pool, size = 8.0M 111104 11:54:40 InnoDB: Completed initialization of buffer pool 111104 11:54:43 InnoDB: Started; log sequence number 0 44233 111104 11:54:44 [Note] Event Scheduler: Loaded 0 events 111104 11:54:44 [Note] /usr/sbin/mysqld: ready for connections. Version: '5.1.54-1ubuntu4' socket: '/var/run/mysqld/mysqld.sock' port: 3306 (Ubuntu Nov 23, 2011 at 10:58
  • Hey, that looks like an improvement; 111 is Connection refused. Did you restart the server after re-creating the socket? Is the server configured to use that pathname?
    – sarnold
    Nov 23, 2011 at 10:58
  • 1
    mysql.sock is not a pipe/fifo, it's a local unix socket. you cannot create that , the mysql server have to create it when it starts. (It might not if there's wrong permissions on the directory, or the server creates the socket in some other directory than where the clients look)
    – nos
    Jun 30, 2012 at 12:57
  • 1
    I encountered a similar problem after running an rsync command to restore a partial backup of certain file folders under the root filesystem (ie: rsync -avc ${SOME_RESTORE_DIR}/ / though not including /var/lib/mysql ). In my case, the permissions of / were set to 700 after this operation, which prevented mysqld from starting. To fix it, I had to chmod 755 / and restart mysqld. This probably would have caused many problems on the server too if not found ;-)
    – TrinitronX
    Oct 23, 2012 at 19:32
0

Did you check that the mysql server mysqld is running? Also, check the system message log to see if it is complaining about anything.

1
  • It was running yes, although its not currently starting up. Seeing below comment. Nov 23, 2011 at 10:57
0

Did you try to remove .lock file and restart mysqld ?

1
  • Where would this .lock file be? Nov 23, 2011 at 10:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.