I am trying to use my flash drive to run mysql, i.e. I want to use my flash drive to do all the operations of mysql in place of hard disk. I have followed the document of digital ocean to move the mysql data directory mentioned here.

System information:

Ubuntu 16.04 LTS

Flash Drive formatted to Ext4
Permission of the flash drive kept as 777

User group changed to mysql of the flash drive
mysql  Ver 14.14 Distrib 5.7.23, for Linux (x86_64) using  EditLine wrapper

After following the exact steps, whenever I want to start the mysql service it throws me Permission Denied

Error :

**mysqld: Can't change dir to '/media/user_name/flash_drive_ID/mysql/' (Errcode: 13 - Permission denied)**

**mysqld[7929]: 2018-08-10T07:50:41.588660Z 0 [Warning] Can't create test file /media/username/flash_drive_ID/mysql/user_name.lower-test**

**mysqld[7929]: 2018-08-10T07:50:41.588782Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.23-0ubuntu0.16.04.1) starting as process 7929 ...**
**systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE**

Disclaimer: I already know the adverse effect of Wear Levelling but still hope to find a verbose solution as the requirement set is such.

If someone can explain what needs to be done here, it will be really helpful to me. All the solutions that exist in the web is not clearly stating what needs to be done.

  • I suspect that mysql doesn't have execute permissions on /media/user_name and thus can't navigate any further than /media. Check the permissions of all folders in the path. – danzel Aug 10 at 10:11
  • I already used chown -R mysql:mysql /<location to flash drive>/mysql. If you are not suggesting this can you please elaborate what commands needs to be fired! – sayan biswas Aug 10 at 10:48
  • chown -R operates on the specified directory and everything inside that directory, but I was talking about the directories above the specified directory, i.e. /media, /media/user_name and /media/user_name/flash_drive_ID. The mysql user needs execute permissions in all of them to be able to navigate to /media/user_name/flash_drive_ID/mysql, and I doubt that they have execute permissions on /media/user_name. Using ls -ld /media/user_name and getfacl /media/user_name will show you who has execute permissions. – danzel Aug 10 at 11:03
  • Thanks, it got resolved as soon as I changed the permission of /media and /user_name to mysql. – sayan biswas Aug 10 at 12:21

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.