Question

Moving MySQL tmpdir to volume mounted on droplet

I want to move my tmpdir to a mounted volume on my ubuntu droplet.

I created the 50G volume, mounted it with these steps, per the config instructions

# Create a mount point for your volume:
$ mkdir -p /mnt/volume_nyc3_01

# Mount your volume at the newly-created mount point:
$ mount -o discard,defaults,noatime /dev/disk/by-id/scsi-0DO_Volume_volume-nyc3-01 /mnt/volume_nyc3_01

# Change fstab so the volume will be mounted after a reboot
$ echo '/dev/disk/by-id/scsi-0DO_Volume_volume-nyc3-01 /mnt/volume_nyc3_01 ext4 defaults,nofail,discard 0 0' | sudo tee -a /etc/fstab

and then changed the permissions on /mnt/volume_nyc3_01 as follows


chown -R mysql:mysql /mnt/
chmod 777 /mnt

everything is properly mounted


Filesystem     1K-blocks     Used Available Use% Mounted on
tmpfs             400592     1060    399532   1% /run
/dev/vda1       25215872 17595240   7604248  70% /
tmpfs            2002948        0   2002948   0% /dev/shm
tmpfs               5120        0      5120   0% /run/lock
/dev/vda15        106858     7304     99554   7% /boot/efi
tmpfs             400588        4    400584   1% /run/user/1001
/dev/sda          376776       32    340048   1% /mnt/volume_nyc3_01

but I get a permissions error


2023-09-23T00:59:53.320444Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.34-0ubuntu0.22.04.1) starting as process 2638
2023-09-23T00:59:53.329099Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
mysqld: Can't create/write to file '/mnt/volume_nyc3_01/ibKZcmv4' (OS errno 13 - Permission denied)
2023-09-23T00:59:53.343516Z 1 [ERROR] [MY-012576] [InnoDB] Unable to create temporary file inside "/mnt/volume_nyc3_01"; errno: 13
2023-09-23T00:59:53.343550Z 1 [ERROR] [MY-012930] [InnoDB] Plugin initialization aborted with error Generic error.
2023-09-23T00:59:53.343582Z 1 [ERROR] [MY-010334] [Server] Failed to initialize DD Storage Engine
2023-09-23T00:59:53.343809Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2023-09-23T00:59:53.343863Z 0 [ERROR] [MY-010119] [Server] Aborting
2023-09-23T00:59:53.344673Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.34-0ubuntu0.22.04.1)  (Ubuntu).

here’s the directory with permissions


drwxr-xr-x 19 root  root  4.0K Sep 23 00:02 **..**
drwxrwxrwx  3 mysql mysql 4.0K Sep 23 00:56 volume_nyc3_01
drwxrwxrwx  3 mysql mysql 4.0K Sep 23 00:57 .

apparmor is not running. I’m out of ideas. Anyone have a suggestion?

Thanks.


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Turns out it is an apparmor problem, I was just looking at the wrong instructions to ascertain whether it was running. In case it helps anyone else, I modified

/etc/apparmor.d/usr.sbin.mysqld

and added these two lines

/mnt/volume_nyc3_01/ r,
/mnt/volume_nyc3_01/** rwk,

then restarted MySQL, all good.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel