mysql8配置systemctl文件
时间: 2023-12-29 15:06:41 浏览: 213
MySQL 8.x系统配置文件
下面是在 CentOS 7 上配置 MySQL 8 的 systemctl 文件的步骤:
1. 创建 systemctl 文件:
```
sudo nano /usr/lib/systemd/system/mysql.service
```
2. 在文件中添加以下内容:
```
[Unit]
Description=MySQL Server
After=network.target
[Service]
User=mysql
Group=mysql
ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
[Install]
WantedBy=multi-user.target
```
3. 保存并关闭文件。
4. 重新加载 systemctl 文件:
```
sudo systemctl daemon-reload
```
5. 启动 MySQL 服务:
```
sudo systemctl start mysql
```
6. 验证 MySQL 服务是否已成功启动:
```
sudo systemctl status mysql
```
如果 MySQL 服务已成功启动,则应该看到类似以下内容的输出:
```
● mysql.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysql.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2021-07-12 12:00:00 UTC; 3s ago
Main PID: 12345 (mysqld)
Status: "Server is operational"
Tasks: 35
Memory: 142.7M
CGroup: /system.slice/mysql.service
└─12345 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
```
阅读全文