[SLUG] exporting mysql to excel file

Gavin Baker za at supercowpowers.org
Tue Feb 4 22:18:01 GMT 2003


On Tue, 4 Feb 2003 19:54:23 -0000
"Phil Kershaw" <pkershaw at whsmithnet.co.uk> wrote:

> I hope to make the 20th all being well. I'll bring a laptop with
> mandrake on if it helps.

cool :)

> Can anyone recommend a utility to export a mysql database to excel. I
> have a mysql database running on the server and want export the data
> to excel format for use on windows machines.

You can use mysqldump to create a file of comma seperated values which
excel will be able to read.

mkdir /tmp/mydb
chmod a+rwx /tmp/mydb (the mysql process needs to be able to write here)
mysqldump -T /tmp/mydb --fields-terminated-by=',' -p <databasename>

Will create a csv text file for each table in <databasename> and place
it in /tmp/mydb/. If excel messes up the records, make sure it is using
tabs and newlines as the delimiters.

This is assuming you are running the mysql server on the same host as
your shell is running. If not, you will also need to add "-h
<hostname>".

If your mysql username differs from your login name on your machine, you
will also need to add -u <username>.

Let me know if you have any luck.

Regards,
Gav

ps, openoffice.org can use unixodbc to connect straight to a mysql
database, and offers lots of useful features for importing, exporting,
manipulating, creating/designing tables/databases.





More information about the Scarborough mailing list