Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fetch data from MySQL database into Excel

Tags:

mysql

excel

How to fetch data from MySQL database table into Excel?

like image 727
meetpd Avatar asked Dec 08 '25 10:12

meetpd


2 Answers

  1. Install Connector/ODBC

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

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

like image 166
Quassnoi Avatar answered Dec 10 '25 00:12

Quassnoi


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)

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

mysql -e "SELECT * from table1" > file_name

You can then open the csv file in Excel.

like image 43
Johan Avatar answered Dec 10 '25 00:12

Johan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!