linux将mysql加到systemctl命令中

linux中,想将mysql加到systemctl命令中,首先需要确定mysql的安装位置

在/etc/systemd/system目录下新建mysql.service

vim /etc/systemd/system/mysql.service

复制如下内容:确保你自己的mysql路径是否正确

复制代码
[Unit]
Description=MySQL Server
Documentation=man:mysqld(8)
Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target
After=syslog.target

[Install]
WantedBy=multi-user.target

[Service]
User=mysql
Group=mysql
ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf
LimitNOFILE = 5000

重新加载服务

systemctl daemon-reload

如此,就可以用systemctl进行管理了。
首次运行,要先关闭手动启动的mysql,然后用systemctl启动,之后就可以用systemctl进行重启和关闭了;

相关推荐
合作小小程序员小小店10 分钟前
web网页开发,在线%人力资源管理%系统,基于Idea,html,css,jQuery,java,jsp,ssh,mysql。
java·前端·css·数据库·mysql·html·intellij-idea
ASKED_201913 分钟前
常用 Linux 命令大全(文件、网络、时间、进程、数据库、工具全覆盖)
linux·网络·数据库
a123560mh1 小时前
国产信创操作系统银河麒麟常见软件适配(MongoDB、 Redis、Nginx、Tomcat)
linux·redis·nginx·mongodb·tomcat·kylin
赖small强1 小时前
【Linux驱动开发】Linux MMC子系统技术分析报告 - 第二部分:协议实现与性能优化
linux·驱动开发·mmc
SongYuLong的博客1 小时前
Ubuntu24.04搭建GitLab服务器
运维·服务器·gitlab
guygg881 小时前
Linux服务器上安装配置GitLab
linux·运维·gitlab
RokFile1 小时前
SysInfoKeeper是一款面向 Linux/Unix 的硬件变动检测 CLI 工具
运维
地球没有花1 小时前
gitlab cicd 模块解释
运维·ci/cd·gitlab
百***35511 小时前
Linux(CentOS)安装 Nginx
linux·nginx·centos
小坏讲微服务2 小时前
Docker-compose搭建Docker Hub镜像仓库整合SpringBootCloud
运维·分布式·spring cloud·docker·云原生·容器·eureka