Why is “mysqld.pid” and “mysqld.sock” missing from my system even though the values are set in “my.cnf?”
Even though the locations for mysqld.pid
and mysqld.sock
are set in my server’s my.cnf
, the directory doesn’t exist so those files are never created. This will fix that:
First create the mysqld/
directory in /var/run/
like this:
sudo mkdir -p /var/run/mysqld/
Then create a mysqld.pid
file with touch
:
sudo touch /var/run/mysqld/mysqld.pid
Next create a mysqld.sock
file with touch
:
sudo touch /var/run/mysqld/mysqld.sock
Now change the ownerships of the directory and files to mysql:mysql
like this:
sudo chown mysql:mysql -R /var/run/mysqld
And restart MySQL like this to get those files set and created:
sudo service mysql restart
When that’s all done, MySQL will be able to to create the mysqld.pid
and mysqld.sock
files as expected.
Related videos on Youtube
Giacomo1968
Updated on September 18, 2022Comments
-
Giacomo1968 over 1 year
I was working on an answer to this question—on one of my Ubuntu 12.04.5 development servers—and realized that the MySQL install was not creating
mysqld.pid
andmysqld.sock
files despite their paths being explicitly set inmy.cnf
like this:[mysqld] # # * Basic Settings # user = mysql pid-file = /var/run/mysqld/mysqld.pid socket = /var/run/mysqld/mysqld.sock port = 3306 basedir = /usr datadir = /var/lib/mysql tmpdir = /tmp lc-messages-dir = /usr/share/mysql skip-external-locking
Why would this happen and what can be done to resolve the issue?