通常我們都建議不要把mysql的datadir設置為文件系統的根目錄,否則,
show database的時候,會發現一個 奇怪的db: #mysql50#lost+found
mysql [localhost] {msandbox} (test) > SHOW DATABASES;
+---------------------+
| DATABASE |
+---------------------+
| information_schema |
| #mysql50#lost+found |
| mysql |
| performance_schema |
| test |
+---------------------+
5 ROWS IN SET (0.00 sec)
mysql [localhost] {msandbox} (test) > USE \#mysql50\#lost+found
DATABASE changed
mysql [localhost] {msandbox} (#mysql50#lost+found) >
mysql [localhost] {msandbox} (#mysql50#lost+found) > SHOW TABLES;
Empty SET (0.00 sec)
mysql [localhost] {msandbox} (#mysql50#lost+found) > DROP DATABASE \#mysql50\#lost+found;
ERROR 1064 (42000): You have an error IN your SQL syntax; CHECK the manual that corresponds TO your MySQL server version FOR the RIGHT syntax TO USE near '+found' at line 1
因為在根目錄中存在一個目錄,名為 lost+found,而它的名字又不符合mysql5的命名規范,所以就被附加了 #mysql50#在名字前面。
可以使用 ignore-db-dir (全部小寫) 來忽略它。
ignore-db-dir=lost+found
寫入my.cnf,重啟mysqld
mysql [localhost] {msandbox} ((NONE)) > SHOW DATABASES;
+--------------------+
| DATABASE |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 ROWS IN SET (0.00 sec)
如果有多個需要忽略的dir, 就重復多次這條opt:
ignore-db-dir=lost+found
ignore-db-dir=aaaa
ignore-db-dir=花容