简体   繁体   中英

How to skip already created tables while importing mysql dump by command line

Is there any way to skip already created tables while importing ? I am trying to import 2GB of database using command prompt but the operation is aborted by mistake. Now if i will do the import again it will drop each table and create it again, That will take very long time.

I want to skip those tables from import which is already created or can i start it from where it was aborted ? I am using this command

mysql -u root -p my_database_name < db_dump.sql

Run your dump through a filter which replaces each 'CREATE TABLE' with 'CREATE TABLE IF NOT EXISTS', like in

cat db_dump_sql | sed "s/CREATE TABLE /CREATE TABLE IF NOT EXISTS /g" | mysql -uroot -p my_database_name

Or edit db_dump.sql and search/replace interactively.

  1. rename table name to new table name
  2. add ignore keyword, example (insert ignore into table)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM