I'm running mysql 8 under Xubuntu 20.04. I needed more space for my database so I moved it using rsync. I then updated /etc/mysql/mysql.conf.d/mysqld.cnf to my new datadir. I then ran sudo systemctl start mysql
which failed: mysql.service: Start request repeated too quickly.
My /var/log/mysql/mysql.log file shows:
/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).
The main error seems to be
Failed to create file(file: '/var/lib/mysql/auto.cnf', errno 13)
which is understandable as /var/lib/mysql doesn't exist any more.
I've also checked that the new datadir has correct permissions
/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?