systemctl start mysqld.service显示Failed to issue method call: No such file or directory

在centos7中开机启动mysql报错

1
2
3

[root@zouhongzhao zou]# systemctl enable mysqld.service
Failed to issue method call: No such file or directory

 

 

解决办法:

vi /etc/systemd/system/mysqld.service

写入以下内容:

1
2
3
4
5
6
7
8
9
10
11
12
[Unit]
Description=MySQL Server
After=network.target

[Service]
ExecStart=/usr/bin/mysqld --defaults-file=/etc/mysql/my.cnf --datadir=/var/lib/mysql --socket=/var/run/mysqld/mysqld.sock
User=mysql
Group=mysql
WorkingDirectory=/usr

[Install]
WantedBy=multi-user.target

`
 

 

 

systemctl daemon-reload

systemctl enable mysqld.service

 

就ok了。

因为mysqld服务是个虚拟的单元,需要自己建文件。

 

mysqld.service is a “virtual” unit – it doesn’t exist on the filesystem, it’s just part of systemd’s compatibility layer. You can start it and systemd will run the legacy /etc/rc.d/mysqld initscript, but you cannot systemctl enable it because you need a real .service file which could be symlinked into the proper place.

坚持原创技术分享,您的支持将鼓励我继续创作!