我的MySQL日志显示重复的错误:
141223 5:47:21 [ERROR] Invalid (old?) table or database name 'lost+found'
我有一个数据库名为#mysql50#lost+found
但我似乎无法删除它。
mysql> show databases; +---------------------+ | Database | +---------------------+ | information_schema | | maindatabas | | maindatabas_help | | maindatabas_tracker | | gitlabhq_production | | locations | | #mysql50#lost+found | | mysql | | osticket | | performance_schema | +---------------------+ 10 rows in set (0.00 sec) mysql> DROP DATABASE `#mysql50#lost+found`; ERROR 1008 (HY000): Can't drop database '#mysql50#lost+found'; database doesn't exist mysql>
我正在运行服务器版本:5.5.40由CentOS 6上的IUS社区项目分发。
每个MySQL在CentOS 6x(不是5x)上运行得非常慢 ,我的数据块在ext3上,其中barrier = 0选项。
是什么原因导致了这个错误,又如何消除呢?
它看起来像你的datadir
是在自己的文件系统。
像Unix下的大多数FSes一样,Ext文件系统的根目录有一个名为lost+found
的目录。 它存在是为了允许在fscked文件系统不一致的情况下将文件分离(也就是说,它们有内容,但没有关联的目录条目),以便在某处重新连接(请参阅https://unix.stackexchange.com/问题/ 18154 /这是什么目的的丢失文件夹在Linux和UNIX的更多细节)。 这个目的在灾难恢复中很重要,所以你不应该删除这个目录。
当安装包含该目录的文件系统的安装点被完全授予一个期望该安装点中的所有内容属于该应用程序的应用程序时,就会出现问题。 MySQL就是这样,它试图将lost+found
目录解释为与db有关的东西,并且(不是不合理的)失败。
最好的办法是不要将整个FS专用于某个应用程序,而是将FS安装在某个应用程序非特定的安装点上,例如/data1
,在该目录下创build一个子目录,例如/data1/mysql
,然后重新configuration应用程序将该目录用作其数据目录。
MadHatter解释了错误。 但是从那时起,时代已经改变了,现在MySQL(自5.6.2开始)可以忽略这个目录。 只需将此语句添加到/etc/mysql/my.cnf
文件中:
ignore-db-dir=lost+found
MySQL重新启动后,您可以使用命令检查它:
show global variables like 'ignore_db_dirs';
如果要忽略多个目录,则需要分别指定每个目录的选项。
资料来源: http : //www.chriscalender.com/ignoring-the-lostfound-directory-in-your-datadir/
由于我们的MySQL还不了解ignore_db_dirs
,所以我做了
# chmod 0 lost+found
解决了(这个)问题。
如果您正在使用MariaDB,则在CentOS 7.2下my.cnf的位置在
/etc/my.cnf
您可以使用重新启动服务
systemctl restart mariadb.service
ignore-db-dir应放在[mysqld]部分之下,而不要放在[mysqld_safe]之下。
[mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock ignore-db-dir=lost+found # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 # Settings user and group are ignored when systemd is used. # If you need to run mysqld under a different user or group, # customize your systemd unit file for mariadb according to the # instructions in http://fedoraproject.org/wiki/Systemd [mysqld_safe] log-error=/var/log/mariadb/mariadb.log pid-file=/var/run/mariadb/mariadb.pid # # include all files from the config directory # !includedir /etc/my.cnf.d