执行mysql命令:
service mysqld status
Usage: mysqld {start|stop|restart|reload|force-reload|status} [ MySQL server options ]
设置mysql开机自启需在 /etc/rc.d 目录下 rc.local 文件中添加 service mysqld start
cd /etc/rc.d
vi rc.local
service mysqld start
chmod +x /etc/rc.d/rc.local(赋权限)
rc.local文件内容:(翻译下文件注释内容就知道service mysqld start加上后,还需要给文件赋权限,粗体字部分)
#!/bin/bash
#THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#It is highly advisable to create own systemd services or udev rules
#to run scripts during boot instead of using this file.
#In contrast to previous versions due to parallel execution during boot
#this script will NOT be run after all other services.
#Please note that you must run ‘chmod +x /etc/rc.d/rc.local’ to ensure
#that this script will be executed during boot.