Mysql-hxx-uxx-pxx-e "query statement" db> file example: mysql-h127.0.0.1-uroot-p000000-e "select * from a" test> 1.txt host ip user password query statement database filename: mysql-h127.0.0.1-uroot-p000000-N-e "select * from a" test> 1.txt host ip user password query statement database filename or mysql-hxxx-uxx-pxx select * from table into outfile 'xxx.txt '; for example: mysql-h127.0.0.1-uroot-p000000 select * from a into outfile '1.txt '; the two methods have the same effect. The second method is mysql documentation: SELECT [select options go here] INTO {OUTFILE | DUMPFILE} filename EXPORT_OPTIONS FROM table_references [additional select options go here] example: mysql-h127.0.0.1-uroot-p000000 select * from a into outfile "1.txt" fields terminated by '\ t' lines terminated by' \ r \ N': use mysql-e to execute the SQL statement mysql-hxx-uxx-pxx-e "query statement" db for Exported Files. For example: mysql-h127.0.0.1-uroot-p000000-e "select * from a into outfile '1.txt 'fields terminated ', 'Lines terminated by '\ r \ N' "test if you do not want to output column name information: mysql-h127.0.0.1-uroot-p000000-N-e "select * from a into outfile '1.txt 'fields terminated ', 'Lines terminated by '\ r \ N' "test by default, the files exported by mysql-e are separated by" \ t, rows are separated by "\ r \ n" (dos), and rows are separated by "\ n" (unix append method: select col002, col005, col004, col008 into outfile 'e:/mysql/i0812.txt 'fields terminated by' | 'Lines terminated by '\ r \ n' from a where col003 in (select col001 from qdbm) order by col005;
Author zhanghe086