简体   繁体   English

使用mysql命令导出表数据(不是mysqldump)

[英]export table data using mysql command (not mysqldump)

I want to do an export of a table and we do not have mysqldump installed. 我想导出表,但没有安装mysqldump。

I thought I can do this: 我以为我可以做到这一点:

root:~> mysql news media > news.media.7.26.2016.sql

where news is the database name and media is the table name news is the database name and media is the table name

it doesn't seem to work correctly. 它似乎无法正常工作。

Your command tries to mimic mysqldump but mysql does not have a table parameter. 您的命令尝试模仿mysqldumpmysql没有表参数。 You could run it like this: 您可以这样运行它:

mysql -D news -e "SELECT * FROM media" > news.media.7.26.2016.txt

That will work but you won't get nice SQL statements in the output, just tabular data export. 那会起作用,但是您不会在输出中得到漂亮的SQL语句,而只是表格数据导出。

I mean that you may (or may not) run into problems when importing the data back. 我的意思是,导入数据时,您可能会(也可能不会)遇到问题。 There's a chance to use 有机会使用

mysql -D news -e "LOAD DATA INFILE 'news.media.7.26.2016.txt' INTO TABLE media"

but I do not have much experience with that. 但是我对此没有太多经验。 First of your concerns is secure-file-priv setting that has been made strict starting in MySQL 5.7.6. 首先要关注的是从MySQL 5.7.6开始严格执行的secure-file-priv设置。 Second, I would be a tad bit nervous about preserving data types. 第二,对于保存数据类型,我会有点紧张。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM