0

So, this page is what I'm using as a manual:

Different locations for MySQL databases?

I'm trying to store my database on USB (whether a good idea or not, please tell me how to do this if there is a way). mysql works fine with a soft link that is linked to another folder on the computer. Of course that folder's ownership changed with chown -R mysql:mysql /file.

The first problem I encountered when doing this with USB is that, I couldn't use chown when the current directory is in the usb. My usb's file system is vfat. What I learnt from my research is that "vfat" or "fat32" file system has no support for a security. And that the files in usb could have "immutable" attribute. I couldn't use lsattr nor chattr to check if they are immutable or to eliminate the immutable tag.

I manually mounted the USB so that its "uid" and "gid" are "mysql". I run id -u mysql and id -g mysql, and those turned out to be 116 and 125. Then I used sudo mount -t vfat /dev/sdb1 /media/external -o uid=116,gid=125,utf8,dmask=007,fmask=117 to mount my usb. When I lsblk, it is mounted. I was little uncomfortable with the fact that EVERYTHING in my USB will be mysql:mysql, but I wasn't able to find how to set different owner for folders in the same USB.

Used https://help.ubuntu.com/community/Mount/USB this as a manual.

So, after I've done this, when I ls -l in USB, it gives mysql:mysql.

Before doing this, when performing show databases, I think the soft link I made under /var/lib/mysql/ would not appear, but it appears now.

Now, the problem is that when I perform show tables or create tables after choosing the database (soft link) it gives:

ERROR 1018 (HY000): Can't read dir of './Muniverse/' (errno: 13)

I don't know what to do from here.

When I search for "mysql errno: 13", the solutions all suggest chown -R mysql:mysql (or mysql.mysql), which I think it is already done since when I ls -l in USB, it APPEARS that the the owner and group IS "mysql".

Maybe it only APPEARS as it is? Or is this not working because the files are "immutable"?

However, referring to man manual, there exists "sys_immutable" option that is not set by default.

What am I doing or what have I done wrong?

NOTE: So, basically, I can make the soft link for folders on the computer to work in mysql but not on USB.

===========================

FYI, for those who are as noob as I am in Linux, I was able to format USB to ext4 on LINUX. My windows 10 computer didn't have option for "ext4". And the proof that I think is useful is that when I do lsattr, it now prints attributes and stuff.

link: formatting USB Flash memory for ubuntu ext4

1 Answers1

0

Use EXT on the USB. You are not going to be using the MySQL database outside of Linux anyways so use a native filesystem. That will fix all problems you have with permissions. The errno 13 is a permissions error and more than likely related to your filesystem.

"ln -s" will also work when using EXT. It is a Linux command so it does not work with Microsoft filesystems.

Using an USB for a database is a very bad idea though. Wear leveling is going to be a serious issue. You would be far better off putting the database on a separate partition on your system and copying that partition to a USB and restore the data on another machine where you can use the new database.

Rinzwind
  • 309,379