How to output result to .csv file format?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
ljCharlie
Forum Contributor
Posts: 289
Joined: Wed May 19, 2004 8:23 am

How to output result to .csv file format?

Post by ljCharlie »

How do I output the result to a .csv file format if I telnet to the MySQL database?

ljCharlie
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

ljCharlie
Forum Contributor
Posts: 289
Joined: Wed May 19, 2004 8:23 am

Post by ljCharlie »

Thanks, feyd! That's exactly what I want. I did try to search the msyql.com website but don't remember exactly word or phrase to search for.

ljCharlie
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I searched for "outfile"..
ljCharlie
Forum Contributor
Posts: 289
Joined: Wed May 19, 2004 8:23 am

Post by ljCharlie »

Again, thanks! However, it didn't work. I received an error. Here's what I did.

Code: Select all

mysql> SELECT * INTO OUTFILE 'emailDirectory.csv' FROM email;
The error from the above command is:

ERROR 1045: Access denied for user: 'alumni@localhost' (Using Password: YES)


Any idea on what I did wrong or what's going on? The user name and password I used to logon to the mysql database does have full right. The reason I know this is that the Administrator who gave me this account say so and I was able to do anything using phpMyAdmin to edit/change/delete/add.

Another question, is there a way to do the same thing within phpMyAdmin?

ljCharlie
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

export

Post by phpScott »

look for the export tab and in there you should find all the things neccessary including saving the file somewhere of even printing it to the screen in case you don't hava access to the file structure.
ljCharlie
Forum Contributor
Posts: 289
Joined: Wed May 19, 2004 8:23 am

Post by ljCharlie »

Thanks! I didn't see the export tab what I did see something in phpMyAdmin to export to a .csv file format.

Again, thanks!

ljCharlie
Post Reply