I had successfully imported a database using command line, but now my pain area is how to import a single table with its data to the existing database using command line.
相关问题
- sqlyog export query result as csv
- NOT DISTINCT query in mySQL
- MySQL: conduct a basic search
- Why sometimes there is one of more gap(s) in the v
- How to reimport module with ES6 import
Command Line
Import / Export for single table:
Exporting table schema
This will create a file named test.sql and creates table sql command to create table table_name.
Importing data into table
Make sure your test.sql file is in the same directory, if not navigate through the path and then run the command.
It would be combination of
EXPORT INTO OUTFILE
andLOAD DATA INFILE
You need to export that single table with
EXPORT INTO OUTFILE
, this will export table data to a file. You can import that particular table usingLOAD DATA INFILE
Refer doc1 , doc2
Linux :
In command line
put your table in example.sql
Import / Export for single table:
Export table schema
This will create a file named
example.sql
at the path mentioned and write thecreate table
sql command to create tabletableName
.Import data into table
This command needs an sql file containing data in form of
insert
statements for tabletableName
. All theinsert
statements will be executed and the data will be loaded.you can do it in mysql command instead of linux command.
1.login your mysql.
2.excute this in mysql command:
use DATABASE_NAME;
SET autocommit=0 ; source ABSOLUTE_PATH/TABLE_SQL_FILE.sql ; COMMIT ;
We can import single table using CMD as below: