Linux : MySQL/MariaDB Invalid (old?) table or database name ‘lost+found’

By | September 9, 2023

Encountering the following error in your Linux syslog/message or mysql error log?

mariadbd[16354]: 2023-09-08 22:36:13 2520 [ERROR] Invalid (old?) table or database name 'lost+found'
mariadbd[16354]: message repeated 3 times: [ 2023-09-08 22:36:13 2520 [ERROR] Invalid (old?) table or database name 'lost+found']

This is most likely because your MySQL/MariaDB database folder (eg: /var/lib/mysql) is within a dedicated mountpoint/partition.  Linux filesystem will create a lost+found folder at the root of every mountpoint by design.

Since MySQL/MariaDB will consider every folder under it’s data directory as a database, it is erroring out because it contain no valid SQL files.

Fortunately, there is a build-in feature that allow to ignore directory when defined in the configuration which will remove this cosmetic error.

1. Edit the MySQL/MariaDB server configuration

Example : /etc/mysql/mariadb.conf.d/50-server.cnf

2. Under the [mysqld] statement, uncomment or append the following :

ignore-db-dir = lost+found

3. Restart your database server :

Example : systemctl restart mysqld

The error should no longer occur.  If you’d like to validate the change, use the following MySQL command :

show global variables like 'ignore_db_dirs';

It should output the following :

MariaDB [(none)]> show global variables like 'ignore_db_dirs';
| Variable_name  | Value      |
| ignore_db_dirs | lost+found |
1 row in set (0.002 sec)