Mysql fails to start in LXC container after changing datadir

curious_101

New Member
Jan 29, 2023
1
0
1
Here is my setup:
LXC container running MySQL, I added a second disk on Proxmox host for data and mounted it successfully on host and also inside the LXC container.

Since it was 'unprivileged' I could only do Read only operations on the disk. So I created a username on host and inside LXC container with id as 1000 and did as 1000. Then did the mapping and now I can write to the mounted data disk from inside the LXC container.

No issues with all this so far. Now is when the issues start:

Now I moved the 'datadir' of mysql to a folder in this mounted data disk. After doing this I can no longer get mysql to start. It fails with the error "permission denied". The mounted disk folder was owned by the user with id 1000, since mysql original data folder was owned by "mysql:mysql" I changed the owner to "mysql" but mysql still fails to start. Please advise on how to resolve this issue.
Here is the error I get:

systemctl start mysql
Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xeu mysql.service" for details.

systemctl status mysql
x mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2023-01-29 19:20:13 UTC; 19s ago
Process: 484 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Process: 492 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
Main PID: 492 (code=exited, status=1/FAILURE)
Status: "Server shutdown complete"
Error: 13 (Permission denied)
CPU: 292ms

Jan 29 19:20:13 HomeDevMySql01 systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5.
Jan 29 19:20:13 HomeDevMySql01 systemd[1]: Stopped MySQL Community Server.
Jan 29 19:20:13 HomeDevMySql01 systemd[1]: mysql.service: Start request repeated too quickly.
Jan 29 19:20:13 HomeDevMySql01 systemd[1]: mysql.service: Failed with result 'exit-code'.
Jan 29 19:20:13 HomeDevMySql01 systemd[1]: Failed to start MySQL Community Server.


tail -f /var/log/mysql/error.log
mysqld: File './binlog.index' not found (OS errno 13 - Permission denied)
2023-01-29T19:20:12.702132Z 0 [ERROR] [MY-010119] [Server] Aborting
2023-01-29T19:20:12.702323Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.32-0buntu0.22.04.1) (Ubuntu).
2023-01-29T19:20:13.197361Z 0 [Warning] [MY-010091] [Server] Can't create test file /mnt/datadisk/devarea/databases/mysql/mysqld_tmp_file_case_insensitive_test.lower-test
2023-01-29T19:20:13.197455Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.32-0buntu0.22.04.1) starting as process 492
2023-01-29T19:20:13.200512Z 0 [Warning] [MY-010091] [Server] Can't create test file /mnt/datadisk/devarea/databases/mysql/mysqld_tmp_file_case_insensitive_test.lower-test
2023-01-29T19:20:13.200524Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /mnt/datadisk/devarea/databases/mysql/ is case insensitive
mysqld: File './binlog.index' not found (OS errno 13 - Permission denied)
2023-01-29T19:20:13.201716Z 0 [ERROR] [MY-010119] [Server] Aborting
2023-01-29T19:20:13.201908Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.32-0buntu0.22.04.1) (Ubuntu).