How to ignore directories in data dir MySQL 8.0

I upgraded my database to 8.0 and had to remove the ignore-db-dir in the my.cnf file for it to start up.
When I do a show databases now 2 directories which I don’t have databases in show up.
lost+found and tmp.
Is there a way to ignore those directories in mysql 8.0?

1 Like

Hi @ipcmlr - thanks for posting to the Percona forums!

Best practices say you should create a dedicated directory below the root of your mount point. So for example if your root dir was /mnt/db you could do something like:

systemctl stop mysql
mkdir /mnt/db/mysql
chown mysql /mnt/db/mysql
mv -v /mnt/db/<ALL_FILES> /mnt/db/mysql

Then update your data directory definition in your my.cnf and start up MySQL again. This will ensure you don’t see the lost+found & tmp directories.

1 Like

Thanks.
I’m just doing it the way I’m doing it because it will involve changing monitoring scripts, etc.
The datadirectory is already called /var/lib/mysql/data but is a sepearet mountpoint.
So no way around it? Just live with it?

1 Like

Unfortunately then you’ll have to live with it since you can’t exclude directories from showing up in show databases.
Well perhaps you could set chmod 700 on the directory /var/lib/mysql/data/lost+found but I am not sure how well that would work for filesystem operations

1 Like