在Windows上,像net start mysql
这样的命令将尝试启动MySQL服务。 我正在寻找等价的Linux命令来做到这一点 – 通过Linux命令来改变服务的状态。
很多linux都支持服务命令
service mysql.server start
这与chkconfig有关
[root@iceweasel init.d]# chkconfig --list mysql.server Note: This output shows SysV services only and does not include native systemd services. SysV configuration data might be overridden by native systemd configuration. mysql.server 0:off 1:off 2:on 3:on 4:on 5:on 6:off
否则,你可以做到老式的方式
cd /etc/init.d ./mysql.server start
你的“服务”脚本都存储在/etc/init.d
,所以一般的方法是使用sudo /etc/init.d/mysqld start
(或者你想启动的任何服务)。 现代的Linux发行版有一个类似的事情的service
命令,所以也尝试service mysqld start
。
通常Linux发行版都有一个rc
脚本; 例如:
/etc/rc.d/apache2 restart | stop /etc/rc.d/mysqld start | stop