欧美一区二区三区,国内熟女精品熟女A片视频小说,日本av网,小鲜肉男男GAY做受XXX网站

linux下設置mysql開機自啟動

張吉惟2年前10瀏覽0評論

在Linux系統中使用MySQL時,如果需要在每次開機后自動啟動MySQL服務,需要進行一些設置。下面是詳細的設置方法:

1. 打開終端,使用root賬戶登錄;
2. 切換到/etc/rc.d/init.d目錄;
3. 使用vim或者其他編輯器,新建mysql服務啟動腳本,例如:vim mysql;
4. 在mysql腳本中輸入以下內容:
#!/bin/sh
#
# mysql Startup script for the MySQL server
#
# chkconfig: - 64 36
# description: MySQL database server.
# processname: mysqld
# config: /usr/local/mysql/bin/mysqld_safe
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
[ -x /usr/local/mysql/bin/mysqld_safe ] || exit 1
RETVAL=0
prog="MySQL"
start() {
echo -n $"Starting $prog: "
daemon /usr/local/mysql/bin/mysqld_safe --defaults-file=/usr/local/mysql/my.cnf >/dev/null 2>&1 &
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/mysql
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
killproc mysqld
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/mysql
return $RETVAL
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac
exit $RETVAL
5. 再次使用vim或其他編輯器,打開/etc/inittab文件;
6. 在文件的末尾添加以下命令,讓MySQL服務在開機時自動啟動:

在inittab文件末尾添加:

# Runlevel: 3
# Default runlevel. The runlevels used are:
#   0 - halt (Do NOT set initdefault to this)
#   1 - Single user mode
#   2 - Multiuser, without NFS
#   3 - Full multiuser mode
#   4 - unused
#   5 - X11
#   6 - reboot (Do NOT set initdefault to this)
#
id:3:initdefault:
# System initialization.
si::sysinit:/etc/rc.d/rc.sysinit
# Script to run when going single user (runlevel 1).
su:S:wait:/etc/rc.d/rc.single
# Script to run when going multi user.
rc:2345:wait:/etc/rc.d/rc.multi
# mysql Start
#
mysql:345:wait:/etc/rc.d/init.d/mysql start

7. 保存修改后,重啟系統,就可以看到MySQL服務在啟動時自動開啟了。