网站首页 > 技术教程 正文
CentOS6及以下同有systemctl命令,设置开机启动方法如下:
1.把开机启动脚本(mysqld)copy到文件夹/etc/init.d 或 /etc/rc.d/init.d 中
2.将启动程序的命令添加到 /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 的软链接
3.另一种方法
使用命令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
猜你喜欢
- 2025-05-23 快速搭建 SpringCloud 微服务开发环境的脚手架
- 2025-05-23 「Linux基础」开启SSH服务教程
- 2025-05-23 只有高手才知道的15个 Linux 趣味命令,你玩过几个?
- 2025-05-23 如何优雅的在 Linux 下开机自动重启脚本
- 2025-05-23 Linux 命令速查手册:这 30 个高频指令,拯救 90% 的运维小白!
- 2025-05-23 Linux系统工作管理Job Control详解
- 2025-05-23 Elasticsearch服务自动启动配置指南
- 2025-05-23 Mysql启动选项和配置文件
- 2025-05-23 Linux操作系统之常用命令
- 2025-05-23 Linux下NetworkManager和network的和平共处
你 发表评论:
欢迎- 最近发表
-
- Win11学院:如何在Windows 11上使用WSL安装Ubuntu
- linux移植(Linux移植freemodbus)
- 独家解读:Win10预览版9879为何无法识别硬盘
- 基于Linux系统的本地Yum源搭建与配置(ISO方式、RPM方式)
- Docker镜像瘦身(docker 减小镜像大小)
- 在linux上安装ollama(linux安装locale)
- 渗透测试系统Kali推出Docker镜像(kali linux渗透测试技术详解pdf)
- Linux环境中部署Harbor私有镜像仓库
- linux之间传文件命令之Rsync傻瓜式教程
- 解决ollama在linux中安装或升级时,通过国内镜像缩短安装时长
- 标签列表
-
- 下划线是什么 (87)
- 精美网站 (58)
- qq登录界面 (90)
- nginx 命令 (82)
- nginx .http (73)
- nginx lua (70)
- nginx 重定向 (68)
- Nginx超时 (65)
- nginx 监控 (57)
- odbc (59)
- rar密码破解工具 (62)
- annotation (71)
- 红黑树 (57)
- 智力题 (62)
- php空间申请 (61)
- 按键精灵 注册码 (69)
- 软件测试报告 (59)
- ntcreatefile (64)
- 闪动文字 (56)
- guid (66)
- abap (63)
- mpeg 2 (65)
- column (63)
- dreamweaver教程 (57)
- excel行列转换 (56)
本文暂时没有评论,来添加一个吧(●'◡'●)