mysql 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #!/bin/sh
  2. ########################################################################
  3. # Begin /etc/init.d/mysql
  4. #
  5. # Description : Start MysSQL Server
  6. #
  7. # Author : Bruce Dubbs - bdubbs@linuxfromscratch.org
  8. #
  9. # Version : LFS 7.0
  10. #
  11. ########################################################################
  12. ### BEGIN INIT INFO
  13. # Provides: mysql
  14. # Required-Start: $network
  15. # Should-Start: $remote_fs
  16. # Required-Stop: $network
  17. # Should-Stop: $remote_fs
  18. # Default-Start: 3 4 5
  19. # Default-Stop: 0 1 2 6
  20. # Short-Description: Starts MySQL server.
  21. # Description: Starts MySQL server.
  22. # X-LFS-Provided-By: BLFS / LFS 7.0
  23. ### END INIT INFO
  24. . /lib/lsb/init-functions
  25. #$LastChangedBy: igor $
  26. #$Date: 2014-10-11 03:51:32 -0500 (Sat, 11 Oct 2014) $
  27. PIDFILE=/srv/mysql/`/bin/hostname`.pid
  28. case "$1" in
  29. start)
  30. log_info_msg "Starting MySQL daemon..."
  31. # Make sure the mysql user can create a socket
  32. mkdir -p /run/mysqld
  33. chown mysql.mysql /run/mysqld
  34. if [ -f "$PIDFILE" ]; then
  35. if /bin/ps -e | grep `cat $PIDFILE` | grep mysqld >/dev/null ; then
  36. log_warning_msg "\n mysqld already running!"
  37. exit 0
  38. else
  39. rm -f "$PIDFILE"
  40. if [ -f "$PIDFILE" ]; then
  41. log_failure_msg2
  42. exit 1
  43. fi
  44. fi
  45. fi
  46. /usr/bin/mysqld_safe --user=mysql 2>&1 >/dev/null &
  47. evaluate_retval
  48. ;;
  49. stop)
  50. log_info_msg "Stopping MySQL daemon..."
  51. killproc -p ${PIDFILE} /usr/bin/mysqld
  52. evaluate_retval
  53. ;;
  54. reload)
  55. log_info_msg "Reloading MySQL ..."
  56. killproc -p ${PIDFILE} /usr/bin/mysqld -HUP
  57. evaluate_retval
  58. ;;
  59. restart)
  60. $0 stop
  61. sleep 1
  62. $0 start
  63. ;;
  64. status)
  65. statusproc /usr/bin/mysqld
  66. ;;
  67. *)
  68. echo "Usage: $0 {start|stop|reload|restart|status}"
  69. exit 1
  70. ;;
  71. esac
  72. # End /etc/init.d/mysql