How to import a single table in to mysql database

2019-01-29 17:24发布

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.

标签: mysql import
13条回答
Juvenile、少年°
2楼-- · 2019-01-29 17:36

It works correctly...

C:\>mysql>bin>mysql -u USERNAME DB_NAME < tableNameFile.sql

please note .sql file specified your current database..

查看更多
smile是对你的礼貌
3楼-- · 2019-01-29 17:39

if you already have the desired table on your database, first delete it and then run the command below:

 mysql -u username -p  databasename  < yourtable.sql
查看更多
Luminary・发光体
4楼-- · 2019-01-29 17:39

From server to local(Exporting)

mysqldump -u username -p db_name table_name > path/filename.sql;
mysqldump -u root -p remotelab welcome_ulink > 
/home_local/ladmin/kakalwar/base/welcome_ulink.sql;

From local to server(Importing)

mysql -u username -p -D databasename < path/x/y/z/welcome_queue.sql
mysql -u root -p -D remotelab < 
/home_local/ladmin/kakalwar/instant_status/db_04_12/welcome_queue.sql
查看更多
一夜七次
5楼-- · 2019-01-29 17:42

Export:

mysqldump --user=root databasename > whole.database.sql
mysqldump --user=root databasename onlySingleTableName > single.table.sql

Import:

Whole database:

mysql --user=root wholedatabase < whole.database.sql

Single table:

mysql --user=root databasename < single.table.sql
查看更多
地球回转人心会变
6楼-- · 2019-01-29 17:43

Also its working. In command form

cd C:\wamp\bin\mysql\mysql5.5.8\bin //hit enter
mysql -u -p databasename //-u=root,-p=blank
查看更多
疯言疯语
7楼-- · 2019-01-29 17:44

Importing the Single Table

To import a single table into an existing database you would use the following command:

mysql -u username -p -D database_name < tableName.sql

Note:It is better to use full path of the the sql file tableName.sql

查看更多
登录 后发表回答