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进行重启和关闭了;

相关推荐
n***s90914 小时前
【MySQL基础篇】概述及SQL指令:DDL及DML
sql·mysql·oracle
青青草原技术员灰太狼17 小时前
Nginx的https搭建
linux·服务器·网络
xu_yule17 小时前
网络和Linux网络-4(应用层)序列化和反序列化(网络计算器)
linux·网络
宇钶宇夕17 小时前
三旺 INP314T 网关快速入门指南:从登录到基础配置
运维·自动化·软件工程
2***s67217 小时前
Failed to restart nginx.service Unit nginx.service not found
运维·nginx
计算机毕设小月哥18 小时前
【Hadoop+Spark+python毕设】智能制造生产效能分析与可视化系统、计算机毕业设计、包括数据爬取、Spark、数据分析、数据可视化、Hadoop
后端·python·mysql
w***z5018 小时前
MYSQL 创建索引
数据库·mysql
j***518918 小时前
Java进阶,时间与日期,包装类,正则表达式
java·mysql·正则表达式
YongCheng_Liang18 小时前
Zabbix 6.4 完整部署教程:从环境准备到监控实战
linux·运维·zabbix
小白电脑技术18 小时前
旧电脑安装流畅的系统?用虚拟机先体验一下Linux Mint!
linux·电脑