kconfig --list查看是否添加成功
然后通过service
命令控制
[root@localhost ~]: service mysql start
第二种,通过systemd制作自启动服务
[root@localhost ~]: touch /etc/systemd/system/mysql.service
[root@localhost ~]: vi /etc/systemd/system/mysql.service
配置示例如下:
[Unit]
Description=mysql service
[Service]
Type=forking
ExecStart=/opt/program/mysql/support-files/mysql.server start
ExecStop=/opt/program/mysql/support-files/mysql.server stop
User=mysql
[Install]
WantedBy=multi-user.target
然后通过systemctl
命令控制即可,启动服务和启用自启动
[root@localhost ~]: systemctl start mysql.service
[root@localhost ~]: systemctl enable mysql.service
第三种,通过systemd制作自启动服务,并且通过mysql/bin/mysqld来启动,my.cnf可以自定义位置。(参照于Windows服务的启动配置)
mysql.service
配置示例如下:
[Unit]
Description=mysql service
[Service]
ExecStart=/opt/program/mysql/bin/mysqld --defaults-file=/opt/program/mysql/my.cnf --user=mysql
User=mysql
[Install]
WantedBy=multi-user.target
- 错误:
error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
解决方法:
检查是否有libaio库# rpm -qa|grep libaio
,如果没有则安装# yum install libaio
。