FIX MySQL manager or server PID file could not be found

FIX MySQL manager or server PID file could not be found

گروه آموزش مجموعه تدبیر
Problem – You get these types of errors when you restart mysql

MySQL manager or server PID file could not be found!       [FAILED]
ERROR! MySQL manager or server PID file could not be found!
/etc/init.d/mysql: /usr/local/bin/hostname: not found
Solution
Well don’t panic, just follow these steps to get you out of this situation.  Usually has to do with missing your mysql.sock file.  This is done from the command line, terminal, or ssh.  You will need root access.  If you don’t have command line or root access because this is on a shared hosting server you will have to contact technical support to fix it.
  1. ps -ef |grep mysql|awk ‘{print $2}’|xargs kill -9 (This finds and kills all mysql processes)
  2. touch /tmp/mysql.sock   Other locations are possible. e.x. /var/tmp/mysql.sock
    (creates a new mysql.sock)
  3. chown -R mysql:mysql mysql.sock (Must be in same folder as mysql.sock or specify path)
  4. which mysql (tells you where mysql is.  Output might look like this: /usr/local/mysql/bin/mysql)
  5. /etc/init.d/mysql start (Restarts mysql service)
For Hostname not found
# find / -name hostname
/usr/bin/hostname
/usr/ucb/hostname
# ln -s /usr/bin/hostname /usr/local/bin/hostname
# vi /etc/init.d/mysql
find
basedir=
datadir=
change with
basedir=/usr/local/mysql
datadir=/usr/local/mysql/var
# /etc/init.d/mysql start
NOTE: Your paths may be different, make sure you use the paths found by the find hostname command above.