将以下行添加到 my.cnf 的 [mysqld] 部分后,让 MariaDB 重新启动时出现问题:
datadir = /home/mysql
它不会重新启动。这可能是权限问题。这是保存我所有 SQL 数据的目录。这是 systemctl status mysql.service 显示的内容
● mariadb.service - MariaDB database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Wed 2021-11-10 08:33:00 CST; 36s ago
Docs: man:mysqld(8)
https://mariadb.com/kb/en/library/systemd/
Process: 14438 ExecStart=/usr/lib/mysql/mysql-systemd-helper start (code=exited, status=1/FAILURE)
Process: 14425 ExecStartPre=/usr/lib/mysql/mysql-systemd-helper upgrade (code=exited, status=0/SUCCESS)
Process: 14412 ExecStartPre=/usr/lib/mysql/mysql-systemd-helper install (code=exited, status=0/SUCCESS)
Main PID: 14438 (code=exited, status=1/FAILURE)
Status: "MariaDB server is down"
Nov 10 08:33:00 law-amp3 mysql-systemd-helper[14438]: 2021-11-10 8:33:00 0 [Note] /usr/sbin/mysqld (mysqld 10.4.17-MariaDB-log) starting as process 14438 ...
Nov 10 08:33:00 law-amp3 mysql-systemd-helper[14438]: 2021-11-10 8:33:00 0 [Warning] Could not increase number of max_open_files to more than 1024 (request: 32214)
Nov 10 08:33:00 law-amp3 mysql-systemd-helper[14438]: 2021-11-10 8:33:00 0 [Warning] Changed limits: max_open_files: 1024 max_connections: 151 (was 151) table_cache: 421 (was 2000)
Nov 10 08:33:00 law-amp3 mysql-systemd-helper[14438]: 2021-11-10 8:33:00 0 [Warning] Can't create test file /home/mysql/law-amp3.lower-test
Nov 10 08:33:00 law-amp3 mysql-systemd-helper[14438]: [87B blob data]
Nov 10 08:33:00 law-amp3 mysql-systemd-helper[14438]: 2021-11-10 8:33:00 0 [ERROR] Aborting
Nov 10 08:33:00 law-amp3 systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
Nov 10 08:33:00 law-amp3 systemd[1]: Failed to start MariaDB database server.
Nov 10 08:33:00 law-amp3 systemd[1]: mariadb.service: Unit entered failed state.
Nov 10 08:33:00 law-amp3 systemd[1]: mariadb.service: Failed with result 'exit-code'.
听起来像是权限问题。确保目录的所有者是 mysql。例如
编辑:
查看服务文件是否有 ProtectHome
将 ProtectHome=true 更改为 ProtectHome= false
保存文件
重启 mariadb