如何从 MySQL 数据库中获取数据到 Excel 中

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5715099/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 19:34:13  来源:igfitidea点击:

How to fetch data from MySQL database into Excel

mysqlexcel

提问by meetpd

How to fetch data from MySQL database table into Excel?

如何从 MySQL 数据库表中提取数据到 Excel 中?

回答by Quassnoi

  1. Install Connector/ODBC

  2. Create an ODBC DSN(Control Panel / Administration / ODBCif on Windows)

  3. Import data using Microsoft Query(Data / External Data / From Other Sources / Microsoft Queryin Excel 2007)

  1. 安装 Connector/ODBC

  2. 创建一个ODBC DSNControl Panel / Administration / ODBC如果在 Windows 上)

  3. 使用Microsoft Query( Data / External Data / From Other Sources / Microsoft Queryin Excel 2007)导入数据

回答by Johan

If your server is also your client machine you can do

如果您的服务器也是您的客户端机器,您可以这样做

select * from table1 into outfile 'c:/path/outfile.csv'

(Note the use of forward slashes even on Windows)

(注意即使在 Windows 上也使用正斜杠)

If your server is a remote machine, make sure your have the MySQL client software installed on the client machine and do:

如果您的服务器是远程机器,请确保您在客户端机器上安装了 MySQL 客户端软件并执行:

mysql -e "SELECT * from table1" > file_name

You can then open the csv file in Excel.

然后,您可以在 Excel 中打开 csv 文件。

回答by M Gaidhane

Try out with

试试看

SELECT column1, column1, column1 from tablename INTO OUTFILE "path/CSV/tablename.xls" FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY "\n" <br>

refer http://dev.mysql.com/doc/refman/5.1/en/load-data.html

参考http://dev.mysql.com/doc/refman/5.1/en/load-data.html

回答by álvaro González

I think the easiest way is ODBC. You can download the ODBC driver for MySQL(if you don't have it already). Then, once inside Excel, you can go to "Data-> Obtain external data" (the name and location of the menu items may vary) and pick or create a data source.

我认为最简单的方法是 ODBC。您可以下载MySQLODBC 驱动程序(如果您还没有的话)。然后,在 Excel 中,您可以转到“数据-> 获取外部数据”(菜单项的名称和位置可能会有所不同)并选择或创建数据源。

回答by Teson

odbc-query.

odbc 查询。

excel: /data/get external data...

excel: /data/获取外部数据...