We have moved mysql data directory to another disk, so now /var/lib/mysql is just a mount point to another partition. We set the owner of the /var/lib/mysql directory to mysql.mysql.

But everytime we mount the partition, the ownership changes to root.root. Because of this, we couldn't create additional MySQL database.

Our fstab entry:

/dev/mapper/db-db   /var/lib/mysql    ext3    relatime        0       2

How to change the owner of mount point to user other than root?

8 Answers 8


You need to change the permissions of the mounted filesystem, not of the mount point when the filesystem is not mounted. So mount /var/lib/mysql then chown mysql.mysql /var/lib/mysql. This will change the permissions of the root of the MySQL DB filesystem.

The basic idea is that the filesystem holding the DB needs to be changed, not the mount point, unless its path has some issues, e.g. lib can only be read by root.



mount device mount-point -o uid=foo -o gid=foo

if group need to be changed too

  • 2
    Where the uid foo is the name of the user you want to be the owner of the mount point. And gid foo is the name of the user group, generally the same as the user name. In doubt just type ls -l in your home directory and check the first and second names respectively.
    – Zequez
    Sep 12, 2012 at 17:35
  • 3
    This only works on filesystems that don't store UNIX ownership, like vfat and ntfs. Jul 23, 2021 at 0:00

Important disclaimer (learned that from comments):

uid and gid flags only work on filesystems that don't support Linux permissions schema - ie, FAT and NTFS, among others

Thus this is NOT a correct answer to OP but helpful to others

Add uid and gid like these:

/dev/mapper/db-db  /var/lib/mysql ext3  relatime,rw,exec,uid=frank,gid=www-group        0       2

You can use actual user/groupnames (beware of spaces) or numeric uid, gid values. I added rw and exec which might further help you prevent access troubles (presuming you are on a development system, not a production server).

PS: For even more access (if desired), add ",dir_mode=0777,file_mode=0777"

  • 3
    No, it's relatime. lwn.net/Articles/244829
    – endolith
    Aug 13, 2012 at 16:45
  • 17
    -1 because uid and gid flags only work on filesystems that don't support Linux permissions schema - ie, FAT and NTFS, among others. See askubuntu.com/a/34068/329506 Dec 11, 2015 at 20:38
  • 2
    yeah,i ran into the uid/gid issue - is there a solution?
    – tofutim
    Sep 26, 2016 at 15:49
  • 1
    This helped me with my FAT32 drive. Thank you.
    – Naeem Khan
    Jul 18, 2019 at 18:52

Make sure you change the permissions when the filesystem is not mounted - doing it while mounted has never worked for me.

Additionly, you can add the 'user' option to your fstab, example:

/dev/mapper/db-db   /var/lib/mysql    ext3    relatime,user        0       2

This should also mean that the mount command (if it needs to be called) won't need root privileges to mount that volume. Not changing your fstab will not stop you fixing your issue though!

  • this is right answer
    – QkiZ
    Oct 13 at 22:48

I usually do this on empty unmounted directory

chmod 777 <directory>

Then do

chown -R mysql.mysql <directory>

Then in /etc/fstab do

<device>    <directory>  ext3   user,defaults 0 2

Then use

mount -a

to mount all filesystems listed in /etc/fstab.

This works for me. Give it a try

  • Hi @saudabh. You just saved me a few working hours on this very good answer. Feb 15, 2022 at 9:34

If you want to only do it as part of the mount command line, you can use the -o switch and do:

mount device mount-point -o uid=foo

That will change the owner of the mount point to user foo instead of root.


Recently I had fallen into a similar problem. And this is what I did:

In the /etc/fstab:

UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx /mnt/minimal_dev_env ext4 errors=remount-ro 0 2

In My Ubuntu Clipboard Extension:

Added this following COMBINED command:

sudo mount -a && sudo chown -R mysql:mysql /mnt/minimal_dev_env/mysql && sudo systemctl restart mysql && ls -la /mnt/minimal_dev_env/mysql

for mounting. And,

sudo systemctl stop mysql && sudo umount /mnt/minimal_dev_env/ && ls -la /mnt/minimal_dev_env/

for unmounting.


Would it work to set fstab entry like this?

/dev/mapper/db-db   /var/lib/mysql    ext3    relatime,mode=0755,uid=1000        0       2

where uid is ID of a user returned by "id" command.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .