Home > Database > Mysql Tutorial > MySQL 导出数据到csv文件的命令

MySQL 导出数据到csv文件的命令

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 17:19:09
Original
1430 people have browsed it

1.MySQL导出本地数据库数据到本地文件mysql -A service_db -h your_host -utest -ptestmysqlgt; select * from t_apps where cr

1.MySQL导出本地数据库数据到本地文件

mysql -A service_db -h your_host -utest -ptest

mysql> select * from t_apps where created>'2012-07-02 00:00:00' into outfile /tmp/apps.csv

2.MySQL导出远程数据库数据到本地文件

mysql -A service_db -h your_host -utest -ptest -ss -e "SELECT * from t_apps limit 300;" | sed 's/\t/","/g;s/^/"/;s/$/"/;s/\n//g' > apps.csv

(sed部分可略,尤其是处理包含汉字的数据时)

3.使用mysqldump导出远程或本地数据到本地文件

mysqldump -h your_host -utest -ptest -w "id tt.sql

如果只导数据加上 -t or --no-create- info ;

如果只导结构加上 -d or --no-data;

4. mysqldump不能指定导出的列,变通方法如下:

mysql -u USERNAME --password=PASSWORD --database=DATABASE --execute='SELECT `FIELD`, `FIELD` FROM `TABLE` LIMIT 0, 10000 ' -X > file.csv

linux

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template