ERROR 1813 (HY000) at line 404: Tablespace for table '`xxx`.`xxxxx`' exists.
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ERROR 1813 (HY000) at line 404: Tablespace for table '`xxx`.`xxxxx`' exists.相关的知识,希望对你有一定的参考价值。
今天在进行mysql备份实验时,通过mysqldump命令将主机host1中的所有数据库备份到主机Host2中, 在执行命令时出现了如下错误信息。
[[email protected] tmp]# mysqldump -h 192.168.5.22 -u root --password=1234 --all-databases| mysql -h 192.168.5.33 -uroot --password=1234 ERROR 1813 (HY000) at line 404: Tablespace for table ‘`mysql`.`innodb_index_stats`‘ exists. Please DISCARD the tablespace before IMPORT. mysqldump: Got errno 32 on write
这个错误是说数据库mysql.innodb_index_stats 的表空间已经存在,在导入数据之前需要将这个表空间释放到。根据提示,进入到主机Host2中数据库存放目录中手工删除这些文件,操作如下:
[[email protected] ~]# cd /var/lib/mysql/mysql [[email protected] mysql]# ls columns_priv.frm help_relation.frm procs_priv.frm time_zone.frm columns_priv.MYD help_relation.MYD procs_priv.MYD time_zone_leap_second.frm columns_priv.MYI help_relation.MYI procs_priv.MYI time_zone_leap_second.MYD db.frm help_topic.frm proxies_priv.frm time_zone_leap_second.MYI db.MYD help_topic.MYD proxies_priv.MYD time_zone.MYD db.MYI help_topic.MYI proxies_priv.MYI time_zone.MYI event.frm host.frm servers.frm time_zone_name.frm event.MYD host.MYD servers.MYD time_zone_name.MYD event.MYI host.MYI servers.MYI time_zone_name.MYI func.frm innodb_index_stats.ibd slave_master_info.frm time_zone_transition.frm func.MYD innodb_table_stats.frm slave_master_info.ibd time_zone_transition.MYD func.MYI innodb_table_stats.ibd slave_relay_log_info.frm time_zone_transition.MYI general_log.CSM ndb_binlog_index.frm slave_relay_log_info.ibd time_zone_transition_type.frm general_log.CSV ndb_binlog_index.MYD slave_worker_info.frm time_zone_transition_type.MYD general_log.frm ndb_binlog_index.MYI slave_worker_info.ibd time_zone_transition_type.MYI help_category.frm plugin.frm slow_log.CSM user.frm help_category.MYD plugin.MYD slow_log.CSV user.MYD help_category.MYI plugin.MYI slow_log.frm user.MYI help_keyword.frm proc.frm tables_priv.frm help_keyword.MYD proc.MYD tables_priv.MYD help_keyword.MYI proc.MYI tables_priv.MYI [[email protected] mysql]# mv innodb_index_stats.ibd /tmp #这里将文件剪切到/tmp目录中去 [[email protected] mysql]# service mysql restart Shutting down MySQL.. [ OK ] Starting MySQL. [ OK ]
重启完成后,进入主机Host1中再次执行备份命令,这时又出现了以下错误:
[[email protected] tmp]# mysqldump -h 192.168.5.22 -u root --password=1234 --all-databases|mysql -h 192.168.5.33 -uroot --password=1234 Warning: Using a password on the command line interface can be insecure. Warning: Using a password on the command line interface can be insecure. ERROR 1813 (HY000) at line 434: Tablespace for table ‘`mysql`.`innodb_table_stats`‘ exists. Please DISCARD the tablespace before IMPORT.
于是再次进入Host2中,删除innodb_table_stats文件,删除之后再次重启mysql服务器
[[email protected] mysql]# mv innodb_table_stats.ibd /tmp [[email protected] mysql]# service mysql restart Shutting down MySQL.. [ OK ] Starting MySQL. [ OK ]
之后,再次进入Host1中执行备份命令,又会出现新的表错误信息,在Host2中执行同样的操作,依次删除文件slave_master_info、slave_relay_log_info、slave_worker_info后,直至不在出现错误信息,主机host1中的数据库全部复制到主机Host2中。
## 主机Host1执行的操作 [[email protected] tmp]# mysqldump -h 192.168.5.22 -u root --password=1234 --all-databases|mysql -h 192.168.5.33 -uroot --password=1234 Warning: Using a password on the command line interface can be insecure. Warning: Using a password on the command line interface can be insecure. ERROR 1813 (HY000) at line 647: Tablespace for table ‘`mysql`.`slave_master_info`‘ exists. Please DISCARD the tablespace before IMPORT. [[email protected] tmp]# mysqldump -h 192.168.5.22 -u root --password=1234 --all-databases|mysql -h 192.168.5.33 -uroot --password=1234 Warning: Using a password on the command line interface can be insecure. Warning: Using a password on the command line interface can be insecure. ERROR 1813 (HY000) at line 691: Tablespace for table ‘`mysql`.`slave_relay_log_info`‘ exists. Please DISCARD the tablespace before IMPORT. [[email protected] tmp]# mysqldump -h 192.168.5.22 -u root --password=1234 --all-databases|mysql -h 192.168.5.33 -uroot --password=1234 Warning: Using a password on the command line interface can be insecure. Warning: Using a password on the command line interface can be insecure. ERROR 1813 (HY000) at line 720: Tablespace for table ‘`mysql`.`slave_worker_info`‘ exists. Please DISCARD the tablespace before IMPORT. [[email protected] tmp]# mysqldump -h 192.168.5.22 -u root --password=1234 --all-databases|mysql -h 192.168.5.33 -uroot --password=1234 Warning: Using a password on the command line interface can be insecure. Warning: Using a password on the command line interface can be insecure. [root[email protected] tmp]# ## 主机Host2中执行的操作 [[email protected] mysql]# mv innodb_table_stats.ibd /tmp [[email protected] mysql]# service mysql restart Shutting down MySQL.. [ OK ] Starting MySQL. [ OK ] [[email protected] mysql]# mv slave_master_info.ibd /tmp [[email protected] mysql]# service mysql restart Shutting down MySQL.. [ OK ] Starting MySQL. [ OK ] [[email protected] mysql]# mv slave_relay_log_info.ibd /tmp [[email protected] mysql]# service mysql restart Shutting down MySQL.. [ OK ] Starting MySQL. [ OK ] [[email protected] mysql]# mv slave_worker_info.ibd /tmp [[email protected] mysql]# service mysql restart Shutting down MySQL.. [ OK ] Starting MySQL. [ OK ]
解决流程如下:
1、关闭所有mysql操作,停止mysql服务。
2、找到安装目录下的数据库文件,应该在你安装目录下的data文件夹下,然后打开你对应的数据库名的文件夹。找到那个表对应的文件,将其删除。数据库中的文件名,应该是和你的表名一一对应的,一个表,两个文件,一个数据文件,一个是日志文件,除了这个还有一个“db.opt”文件不要删除。其他的乱码的文件,和原来你出错的文件全部删除。
3、完了以后重新启动mysql服务,重新添加那个同样名字的表就可以添加成功了。
本文出自 “11978551” 博客,请务必保留此出处http://11988551.blog.51cto.com/11978551/1904987
以上是关于ERROR 1813 (HY000) at line 404: Tablespace for table '`xxx`.`xxxxx`' exists.的主要内容,如果未能解决你的问题,请参考以下文章
ERROR 23 (HY000) at line 29963: Out of resources when opening file
ERROR 1007 (HY000) at line 29: Can‘t create database ‘qz‘; database exists
mysql登陆时出现ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication
主从复制时报:ERROR 1794 (HY000): Slave is not configured or failed to initialize properly. You must at lea
mysql恢复和数据导入的问题(ERROR 2006 (HY000) at line 1016: MySQL server has gone away)
ERROR 1840 (HY000) at line 24: @@GLOBAL.GTID_PURGED can only be set when @@GLOBA