Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid prevent from server restart

My mySQL server on CentOS has been working correctly, but, I am unable to restart mysqld suddenly today.

1) # /etc/rc.d/init.d/mysqld start

shows [failed]

2) see the log

tail /var/log/mysqld.log 
.
.
mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

3) manually put

 /usr/bin/mysqld_safe

151129 15:54:36 mysqld_safe Logging to '/var/log/mysqld.log'.
151129 15:54:37 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
151129 15:54:37 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

4)check config

less /etc/my.cnf

datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

# Recommended in standard MySQL setup
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

5)check mysql directory,every owner ship is belonging to mysql. However I can't fine mysql.sock (this is set in my.cnf)

cd /var/lib/mysql 
ls -la

drwxr-xr-x  5 mysql mysql     4096 11月 29 15:54 2015 .
drwxr-xr-x 21 root  root      4096  6月  2 06:09 2015 ..
-rw-rw----  1 mysql mysql       56  6月  2 05:42 2015 auto.cnf
drwx------  2 mysql mysql     4096 11月 24 11:12 2015 myapp
-rw-rw----  1 mysql mysql 50331648 11月 29 12:30 2015 ib_logfile0
-rw-rw----  1 mysql mysql 50331648 11月 29 12:30 2015 ib_logfile1
-rw-rw----  1 mysql mysql 79691776 11月 29 12:30 2015 ibdata1
drwx------  2 mysql mysql     4096  6月  2 05:42 2015 mysql
drwx------  2 mysql mysql     4096  6月  2 05:42 2015 performance_schema

6) I found there is no mysql.sock in /var/lib/mysql directory, then I try this for test purpose.

touch /var/lib/mysql/mysql.sock

try to restart

/etc/rc.d/init.d/mysqld start

somehow mysql.sock is deleted.

Is there any other things I can try??

like image 823
whitebear Avatar asked Nov 29 '15 16:11

whitebear


People also ask

What is mysqld_safe process?

mysqld_safe is the recommended way to start a mysqld server on Unix. mysqld_safe adds some safety features such as restarting the server when an error occurs and logging runtime information to an error log. A description of error logging is given later in this section.

What is PID file in SQL?

The MySQL PID file is a process identification file that stores the Process ID number of the running MySQL instance. Each time you issue a command to mysql. server , MySQL would look for the PID file to find the Process ID and forward the command to the right process number.


1 Answers

In my case the problem was that mysql tried to create temporary files in /var/run/mysqld and that directory did not exist. I solved the problem by creating the directory manually and setting permissions for it:

mkdir -p /var/run/mysqld
chown mysql:mysql /var/run/mysqld
like image 73
Girts Strazdins Avatar answered Sep 30 '22 05:09

Girts Strazdins