systemctl list-units --all --type=service #查看所有系统服务
systemctl disable mysqld 让服务开机不自启
systemctl enable mysqld 让服务开机启动
systemdctl disable mysqld 查看服务状态
systemdctl stop mysqld 停止服务
systemdctl start mysqld 启动服务
systemdctl restart mysqld 重启服务
systemctl is-enabled mysqld 检查服务是否开机启动
- systemctl list-units --all --type=service
查看所有系统服务
[root@nianhua ~]# systemctl list-units --all --type=service
- systemctl disable mysqld
不让mysqld开启启动
[root@nianhua ~]# systemctl disable mysqld
mysqld.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig mysqld off
- systemctl enable mysqld
让mysqld服务开机启动
[root@nianhua ~]# systemctl enable mysqld
mysqld.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig mysqld on
- systemctl enable mysqld
查看mysqld服务状态
[root@nianhua ~]# systemctl disable mysqld
mysqld.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig mysqld off
[root@nianhua ~]# systemctl enable mysqld
mysqld.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig mysqld on
[root@nianhua ~]# systemctl status mysqld
● mysqld.service - LSB: start and stop MySQL
Loaded: loaded (/etc/rc.d/init.d/mysqld; bad; vendor preset: disabled)
Active: active (running) since 二 2018-11-20 22:34:25 CST; 2h 37min ago
Docs: man:systemd-sysv-generator(8)
CGroup: /system.slice/mysqld.service
├─1137 /bin/sh /www/server/mysql/bin/mysqld_safe --datadir=/www/server/data --pid-file=/www/se...
└─2176 /www/server/mysql/bin/mysqld --basedir=/www/server/mysql --datadir=/www/server/data --p...
11月 20 22:34:21 nianhua systemd[1]: Starting LSB: start and stop MySQL...
11月 20 22:34:25 nianhua mysqld[1107]: Starting MySQL.... SUCCESS!
11月 20 22:34:25 nianhua systemd[1]: Started LSB: start and stop MySQL.
- systemctl stop mysqld
停止mysql服务
[root@nianhua ~]# systemctl stop mysqld
- systemcel start mysqld
启动mysqld服务器
[root@nianhua ~]# systemctl start mysqld
- systemctl restart mysqld
重启mysqld服务
[root@nianhua ~]# systemctl restart mysqld
- systemctl is-enabled mysqld
查看mysqld服务状态
[root@nianhua ~]# systemctl is-enabled mysqld
mysqld.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig mysqld --level=5
enabled