我总是必须在服务器关闭并启动时手动启动它。有人能帮我将它设置为在启动时启动,使用 systemctl enable
[root@localhost ~]# systemctl enable mysqld
Failed to issue method call: Access denied
[root@localhost ~]# systemctl status mysqld
mysqld.service
Loaded: not-found (Reason: No such file or directory)
Active: inactive (dead)
[root@localhost ~]# systemctl status mysql
mysql.service - LSB: start and stop MySQL
Loaded: loaded (/etc/rc.d/init.d/mysql)
Active: active (running) since Mon 2015-10-26 10:18:16 EDT; 2 days ago
CGroup: /system.slice/mysql.service
├─1485 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/trimdb03.pid
└─2523 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --
plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-
error=/var/lib/mysql/mysql.err --pid-file=/...
Oct 26 10:18:06 localhost systemd[1]: Starting LSB: start and stop MySQL...
Oct 26 10:18:16 localhost mysql[1244]: Starting MySQL......... SUCCESS!
Oct 26 10:18:16 localhost systemd[1]: Started LSB: start and stop MySQL.
[root@localhost ~]# systemctl enable mysql
mysql.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig mysql on
The unit files have no [Install] section. They are not meant to be enabled
using systemctl.
Possible reasons for having this kind of units are:
1) A unit may be statically enabled by being symlinked from another unit's
.wants/ or .requires/ directory.
2) A unit's purpose may be to act as a helper for some other unit which has
a requirement dependency on it.
3) A unit may be started when needed via activation (socket, path, timer,
D-Bus, udev, scripted systemctl call, ...).
[root@localhost ~]#
答案1
由于某种原因,MySQL 使用的是旧式的 init 脚本,即使在使用 systemd 的 CentOS 7 上也是如此。它们应该已经分发了适当的 systemd 单元文件,但选择不这样做。
启用旧式初始化脚本的正确方法是使用chkconfig
,即:
chkconfig mysql on
如果这仍然失败了,那么您需要对 Oracle 支持联系人大声抱怨。