MySQL导入数据库,但忽略特定表 [英] MySQL import database but ignore specific table
问题描述
我有一个带一个数据库和大约150个表的大型SQL文件.我想使用mysqlimport
导入该数据库,但是,我希望导入过程忽略或跳过几个表.导入所有表但忽略其中一些表的正确语法是什么?谢谢.
I have a large SQL file with one database and about 150 tables. I would like to use mysqlimport
to import that database, however, I would like the import process to ignore or skip over a couple of tables. What is the proper syntax to import all tables, but ignore some of them? Thank you.
推荐答案
mysqlimport
不是导入SQL语句的正确工具.该工具用于导入格式化的文本文件,例如CSV.您要执行的操作是使用以下命令将sql dump直接输入mysql
客户端:
mysqlimport
is not the right tool for importing SQL statements. This tool is meant to import formatted text files such as CSV. What you want to do is feed your sql dump directly to the mysql
client with a command like this one:
bash > mysql -D your_database < your_sql_dump.sql
mysql
和mysqlimport
都不提供您需要的功能.您最好的机会是导入整个转储,然后删除不需要的表.
Neither mysql
nor mysqlimport
provide the feature you need. Your best chance would be importing the whole dump, then dropping the tables you do not want.
如果您有权访问转储的服务器,则可以使用mysqldump --ignore-table=database.table_you_dont_want1 --ignore-table=database.table_you_dont_want2 ...
创建一个新的转储.
If you have access to the server where the dump comes from, then you could create a new dump with mysqldump --ignore-table=database.table_you_dont_want1 --ignore-table=database.table_you_dont_want2 ...
.
这篇关于MySQL导入数据库,但忽略特定表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!