Using mysql command line to export SQL is actually very simple. You only need two steps. First, enter the mysql command line, enter the database name for use, and then enter source test. SQL can export all the data in the Test table. You can use mysqldump and source to export data at www.2cto.com: mysqldump-urott-P5678 -- default-character-set = gb2312-p-h127.0.0.1 Test test1> test1. SQL: mysql-uroot-P5678 -- default-character-set = gb2312-p-h127.0.0.1-e "select * from Test. test1 "> test1. SQL (however, to manually create a table, you can use show create test1 to obtain the table creation statement) Import: www.2cto.com can (under the mysql Command Line) mysql> use Test; mysql> source test1. SQL; if you use the select method to obtain files, you should import them as follows: mysql> l Oad data infile "test. SQL" into table Test. test1; you can view the import status in "show processlist \ G. Sometimes an ERROR occurs: ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails ('test/test1 ', CONSTRAINT 'xxx' foreign key ('A') REFERENCES 'bb' ('A') in this case, you need to delete the foreign key constraints, such: alter table cwealinfo drop foreign key 'xxx'; alternatively, set foreign_key_checks = 0; pay attention to the database version when exporting and importing data, for example, importing data from 4 to 5, it is best to use 4 mysqldump, otherwise it may fail. In addition, you also need to pay attention to character sets. If the character sets of the two libraries are different, this may cause problems, therefore, we recommend that you use "show variables like '% char %'" to check whether you need to adjust character set settings before importing.