1. New query statement file Query.sql, as follows:
The code is as follows |
Copy Code |
Use appdb; Set names UTF8; Select Feedid, city, message from Feed limit 1000; |
The above set names UTF8 statement is the encoding that the facility is currently using, and if the encoding is inconsistent with the database encoding, there will be garbled
2. Implementation is as follows:
The code is as follows |
Copy Code |
[Root@proxy tianqg]# mysql-uroot-p < query.sql > Query.txt |
Enter the password and create the query result file in the current directory Query.txt
TXT file generated above if you want to save as a. sql file we can do the following
The query results can be saved to a writable directory on the server side using the SELECT INTO outfile command:
The code is as follows |
Copy Code |
Mysql> SELECT * from article limit to outfile '/test/article.sql ';
Query OK, affected (0.01 sec) |
The Article.sql file is then downloaded to the local computer and the query result file is imported through the load data native infile into Table command:
The code is as follows |
Copy Code |
Load data local infile "d:/study/article.sql" into table cmstop_article;
|
Affected rows: 150
Time: 0.722ms