我在 Xubuntu 20.04 下运行 mysql 8。我需要更多空间来存储我的数据库,因此我使用 rsync 移动了它。然后我将 /etc/mysql/mysql.conf.d/mysqld.cnf 更新到我的新数据目录。然后我运行,sudo systemctl start mysql
但失败了:mysql.service: Start request repeated too quickly.
我的 /var/log/mysql/mysql.log 文件显示:
/usr/sbin/mysqld (mysqld 8.0.33-0ubuntu0.22.04.2) starting as process 11483
2023-05-25T22:50:49.385036Z 0 [Warning] [MY-010091] [Server] Can't create test file /var/lib/mysql/mysqld_tmp_file_case_insensitive_test.lower-test
2023-05-25T22:50:49.385044Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
2023-05-25T22:50:49.390198Z 0 [Warning] [MY-010075] [Server] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 97f6b237-fb4e-11ed-87f4-448500680687.
mysqld: File '/var/lib/mysql/auto.cnf' not found (OS errno 13 - Permission denied)
2023-05-25T22:50:49.390250Z 0 [ERROR] [MY-010183] [Server] Failed to create file(file: '/var/lib/mysql/auto.cnf', errno 13)
2023-05-25T22:50:49.390259Z 0 [ERROR] [MY-010076] [Server] Initialization of the server's UUID failed because it could not be read from the auto.cnf file. If this is a new server, the initialization failed because it was not possible to generate a new UUID.
2023-05-25T22:50:49.390288Z 0 [ERROR] [MY-010119] [Server] Aborting
2023-05-25T22:50:49.390659Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.33-0ubuntu0.22.04.2) (Ubuntu).
主要错误似乎是
Failed to create file(file: '/var/lib/mysql/auto.cnf', errno 13)
这是可以理解的,因为 /var/lib/mysql 不再存在。我还检查了新的 datadir 是否具有正确的权限
/media/500GB/var/lib$ ls -l
total 4
drwx---r-- 10 mysql mysql 4096 May 25 12:08 mysql
How can I create the auto.cnf file in the correct location?