Reference: http://blog.csdn.net/jiary5201314/article/details/52026816
1.MYSQL exporting a database to a SQL file
Actually very simple, is a statement on it, first we open the CMD, do not go into the MySQL command interface, directly according to the following format to knock the export statement into, and then enter the password can be:
mysqldump-h[Host IP]-u[user name]-p [Database to export]>[exported path//[filename].sql]
Well, it might be a bit of an abstraction, so let's take an example, now that I have a database bookinfodb in MySQL, I'm going to export it and save it to the D drive.
This time we go to the D-disk directory, we can see a bookinfodb.sql file.
2. Import data from a SQL file into MySQL
1> First, we should enter the MySQL command interface in CMD, the format is very simple, that is, mysql-u[user name]-h[host address, default does not write localhost]-p and then enter the password can be
2> creating a database using Create DATRABSE [database name] and selecting the database to use using the use [database name]
3> to import SQL files directly using source [path//*.sql]
The next step is to output a large list of query OK messages.
3. Deposit the results of the query into a table
INSERT INTO TableB select * from TableA;
4. Write the result of the query to the file
Go to MySQL command line, mysql > select * from TableA to OUTFILE '/home/out.txt ';
Import and export SQL files directly using the MySQL command (GO)