将服务文件拷贝到init.d下,并重命名为mysqld
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
赋予可执行权限
chmod +x /etc/init.d/mysqld
将mysql服务加入到开机自启动
[root@localhost support-files]# chkconfig --level 345 mysqld on
# 如果看到mysql的服务,并且3,4,5都是开的话则成功,如果是关,则
[root@localhost support-files]# chkconfig --list
注:该输出结果只显示 SysV 服务,并不包含
原生 systemd 服务。SysV 配置数据
可能被原生 systemd 配置覆盖。
要列出 systemd 服务,请执行 'systemctl list-unit-files'。
查看在具体 target 启用的服务请执行
'systemctl list-dependencies [target]'。
mysqld 0:关 1:关 2:开 3:开 4:开 5:开 6:关
mysql的相关运行命令
查看服务当前运行状态
[root@localhost support-files]# /etc/init.d/mysqld status
ERROR! MySQL is not running
[root@localhost support-files]#
启动mysql服务
[root@localhost support-files]# /etc/init.d/mysqld start
Starting MySQL. SUCCESS!
[root@localhost support-files]# /etc/init.d/mysqld status
SUCCESS! MySQL running (9271)
[root@localhost support-files]#
停止mysql服务
[root@localhost support-files]# /etc/init.d/mysqld stop
Shutting down MySQL.. SUCCESS!
[root@localhost support-files]#
重启mysql服务
[root@localhost support-files]# /etc/init.d/mysqld restart
ERROR! MySQL server PID file could not be found!
Starting MySQL. SUCCESS!
[root@localhost support-files]#
配置修改后重新加载mysql服务
[root@localhost support-files]# /etc/init.d/mysqld reload
SUCCESS! Reloading service MySQL
[root@localhost support-files]#
systemctl 运行mysql
启动mysql服务
systemctl start mysqld
停止mysql服务
systemctl stop mysqld
mysql的运行状态
[root@localhost ~]# systemctl status mysqld
● mysqld.service - LSB: start and stop MySQL
Loaded: loaded (/etc/rc.d/init.d/mysqld; generated)
Active: active (running) since Sat 2021-07-03 17:07:55 CST; 2min 24s ago
Docs: man:systemd-sysv-generator(8)
Process: 1483 ExecStart=/etc/rc.d/init.d/mysqld start (code=exited, status=0/SUCCESS)
Tasks: 38 (limit: 11362)
Memory: 439.5M
CGroup: /system.slice/mysqld.service
├─1494 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local>
└─1721 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugi>
7月 03 17:07:52 localhost.centos8 systemd[1]: Starting LSB: start and stop MySQL...
7月 03 17:07:55 localhost.centos8 mysqld[1483]: Starting MySQL... SUCCESS!
7月 03 17:07:55 localhost.centos8 systemd[1]: Started LSB: start and stop MySQL.
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之家整理,本文链接:https://www.bmabk.com/index.php/post/100310.html