Score:0

Mysql doesn't start after moving var/lib/mysql

mf flag

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?
in flag
Have you checked that the mysql user has permission to access the mount, it's different to the permission for access to the directory/files. IIRC, `mount | grep 500GB` should show the necessary info. You might need to add mysql user to the users group and mount the drive with access for `users`, for example.
MGibbons avatar
mf flag
Through webmin, I checked "Allow Users to mount this filesystem". mount | grep 500GB /dev/sda1 on /media/500GB type ext4 (rw,relatime). Restarted mysql butgot same results as before
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.