[root@VM-8-12-centos ~]# systemctl enable mysql
Failed to execute operation: No such file or directory
systemctl start mysqld
Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.
解決方案:
# 在 /usr/lib/systemd/system/ 路徑下建立 mysql.service
vim /usr/lib/systemd/system/mysql.service
[Unit] Description=MySQL server After=syslog.target network.target [Service] User=mysql Group=mysql Type=forking TimeoutSec=0 #PermissionsStartOnly=true ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf --daemonize LimitNOFILE = 65535 Restart=on-failure RestartSec=3 RestartPreventExitStatus=1 PrivateTmp=false [Install] WantedBy=multi-user.target
# 重新載入systemctl
systemctl daemon-reload
# 啟動|重啟|停止mysql
systemctl start mysql
systemctl restart mysql
systemctl stop mysql
# 設定開機啟動/不啟動mysql服務
systemctl enable mysql
systemctl disable mysql
# 檢視狀態
systemctl status mysql