Home  >  Article  >  Database  >  在命令行导出MySQL数据到excel表

在命令行导出MySQL数据到excel表

WBOY
WBOYOriginal
2016-06-07 16:24:382051browse

有时候需要将 MySQL 的数据导出成 excel,这很简单,无需第三方工具,直接 MySQL 命令行就自带了这样的功能。比如: SELECT * FROM nowamagic into outfile 'D:\\nowamagic.xls'; 双斜杠是带转义识别目录。 当然也可以加入筛选条件,将特定的数据导出成 exce

有时候需要将 MySQL 的数据导出成 excel,这很简单,无需第三方工具,直接 MySQL 命令行就自带了这样的功能。比如:

SELECT * FROM nowamagic into outfile 'D:\\nowamagic.xls';

双斜杠是带转义识别目录。

当然也可以加入筛选条件,将特定的数据导出成 excel,比如:

SELECT name, phone, tel, source FROM nowamagic WHERE q = 'a' into outfile 'D:\\nowamagic.xls';

如果你的数据是 utf-8 编码,可能生成的 excel 会乱码。这不要紧,用文本打开,以 ANSI 另存一下就OK了。

记录一下。

Statement:
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