CentOS6设置开机自启动

第一步:

把开机启动脚本(mysqld)copy到文件夹/etc/init.d 或 /etc/rc.d/init.d 中,

第二步:有两种方法

方法1:

将启动程序的命令添加到 /etc/rc.d/rc.local 文件中,比如:

#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
/etc/init.d/mysqld start  #就是添加这一条语句

注: 
/etc/init.d 是 /etc/rc.d/init.d 的软链接 
/etc/rc.local 是 /etc/rc.d/rc.local 的软链接

方法2:

使用命令chkconfig设置开机启动

chkconfig功能说明:检查,设置系统的各种服务
语法: 
chkconfig [--add][--del][--list][系统服务] 或 
chkconfig [--level<等级代号>][系统服务][on/off/reset]
--add 添加服务
--del 删除服务
--list 查看各服务启动状态

比如设置自启动mysql:

#将mysql启动脚本放入所有脚本运行目录/etc/rc.d/init.d中
cp /lamp/mysql-5.0.41/support-files/mysql.server /etc/rc.d/init.d/mysqld

#改变权限
chown root.root /etc/rc.d/init.d/mysqld

#所有用户都可以执行,单只有root可以修改
chmod 755 /etc/rc.d/init.d/mysqld

#将mysqld 放入linux启动管理体系中
chkconfig --add mysqld

#查看全部服务在各运行级状态
chkconfig --list mysqld

#只要运行级别3启动,其他都关闭
chkconfig --levels 245 mysqld off
  • 2
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

qq_26182553

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值