Follow us on Social Media:

MySQL Database Administrator

Boost Your Quick Knowledge in MySQL DBA Work, Concepts, Tips and Trick

Saturday, 31 March 2018

MySQL Server Startup Script file: MySQL pid-file / Socket file- mysqld.sock

What is MySQL pid-file ?

MySQL server create this file automatically on server startup . In this file the server should write its process ID.

If this option is not given, mysql.server uses a default value of


# Basic safe settings

log-error = /var/log/getmysql.log

pid-file = /var/lib/mysql/ 

mysql> show variables like '%pid%';
| Variable_name | Value                         |
| pid_file      | /var/lib/mysql/   |
Some time on mysqld startup ,You are facing some issues like..
  • mysql pid file missing !!
  • mysql pid not found !!
  • mysql pid permission denied !!
  • mysql pid error !!
  • mysql pid file does not exist !! etc...

PID file should automatically created when you start mysql service. but if you face any of mentioned error you need to manually delete existing pid and then check the required permissions (0777) on PID file directory.
chmod 0777 /var/lib/mysql/ib_logfile0
chmod 0777 /var/lib/mysql/ib_logfile1
chown -R mysql:root /var/lib/mysql
After that MySQL service will start properly .

What is MySQL Socket file / mysql.sock ?

MySQL Socket file does not contains any data or it is not a normal file like .log/.ini/.config/.txt etc.
MySQL automatically create this file on server startup. This file is just like a PIPE which MySQL use it as pipe to exchanges network packets between a client and server. It is only used locally.
# Basic settings
user = mysql 
datadir = /var/lib/mysql 
socket = /var/lib/mysql/mysql.sock 
In server startup,if you face any error like
  • mysql.sock file missing !!
  • mysql.sock not found !!
  • mysql.sock permission denied !!
  • mysql.sock error !!
  • mysql.sock file does not exist !! etc...

You need to manually delete existing .sock file and then check the required permissions (0777) on .sock file directory.

No comments:

Please Like and Subscribe us ....

Please visit the website on daily basis , Your New articles will publish at any moment. Please Subscribe us for getting Latest Updates...