Search code examples
mysqlmysqlimport

how import a mysqldump file locally


I want to import an sqldump file in my database "dbname" into the table "data" without using the network interface.

when i import the file via

mysql dbname -u databaseuser -pdatabasepass<data.sql

this is really slow on my ubuntu 12.04

but when i use this instead:

mysqlimport -u databaseuser -pdatabasepass --local data.sql

it is as fast as normal.

i think, because on my mashine it is parsing each line separately when using "mysql" and "<"

is there a way to use the mysqlimport syntax for importing an sql-file with CREATE and DROP TABLE stuff?

maybe just split the upper part in the sql-dump (with the drop table and create table statement) automatically and then only send the rest of the file with the INPUT-statements to mysqlinsert, that should work


Solution

  • You can use this script: How do I split the output from mysqldump into smaller files?

    and modify it, so you have only the create-statements in one file and the data statements in another.