问题描述
我想避免使用 mysqldump,因为它以仅便于 mysql 读取的形式输出.CSV 似乎更通用(每表一个文件就可以了).但是,如果 mysqldump 有优势,我全神贯注.另外,我想要一些可以从命令行(linux)运行的东西.如果那是一个 mysql 脚本,那么有关如何制作这样东西的指针会很有帮助.
I'd like to avoid mysqldump since that outputs in a form that is only convenient for mysql to read. CSV seems more universal (one file per table is fine). But if there are advantages to mysqldump, I'm all ears. Also, I'd like something I can run from the command line (linux). If that's a mysql script, pointers to how to make such a thing would be helpful.
推荐答案
如果你可以处理 table-at-a-time,并且你的数据不是二进制的,使用 -B 选项来mysql 命令.使用此选项,它将生成可以很容易地导入 Excel 等的 TSV(制表符分隔)文件:
If you can cope with table-at-a-time, and your data is not binary, use the -B option to the mysql command. With this option it'll generate TSV (tab separated) files which can import into Excel, etc, quite easily:
% echo 'SELECT * FROM table' | mysql -B -uxxx -pyyy database
或者,如果您可以直接访问服务器的文件系统,请使用 SELECT INTO OUTFILE 可以生成真正的CSV文件:
Alternatively, if you've got direct access to the server's file system, use SELECT INTO OUTFILE which can generate real CSV files:
SELECT * INTO OUTFILE 'table.csv'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM table
这篇关于从命令行将 mysql 数据库转储到纯文本 (CSV) 备份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)