Take the 2-minute tour ×

I need to export a table from phpmyadmin to a comma delimited text file. I think there is a code but can't seem to find it. I found one but it doesnt work.

I need to export this table because I need to organize it and sort it and add another column so I can add data to this column.

How can I do this please?

Many thanks

share|improve this question

4 Answers 4

up vote 8 down vote accepted

In PHPAdmin, if I recall correctly, there is an Export tab. If you click on that, you can select the table(s) you want to export and which format you would like to export the data in. CSV, .zip, .gzip, etc...

share|improve this answer
Yes you are right. However I forgot a small detail. I want to export a table but sorted by ID. Can I do this? Currently, it is a bit random. For instance, you have from 1-19 then 5325, then 22,23, and so on... –  seedeg Nov 26 '09 at 9:11
Ok I managed to sort all columns from excel. –  seedeg Nov 26 '09 at 9:17

Select the database and click the 'Export' tab. Select the table to export. Use CSV as the format.

share|improve this answer

Execute this statement:

SELECT * FROM `table_name`
 INTO OUTFILE 'directory' ->e.g /tmp/myTable.csv(Linux) or C:\myTable.csv(Windows)
share|improve this answer
Hi, there! I used your SQL statement but there is no .txt created in the directory (C:\myTable.csv), but when i call the same statement it returns me: 1086 - File 'C:myTableTest.csv' already exists What's the problem??? Thanks, Tom –  user608586 Feb 8 '11 at 18:18
@Tom: You need to either pick a new name for the output file, rename the original one, or do this in a way that will overwrite the original file. –  Robert Harvey Feb 8 '11 at 18:20
@Robert: thanks a lot for so quick response!! my problem is that the C:myTableTest.csv does not exist!!When i run the statement first time everything it's ok,no erros. When i go to my disk C to find myTableTest.csv file,this file doesn't exist!!But when i recall the statement it returns the error 1086 - File 'C:myTableTest.csv' already exists –  user608586 Feb 8 '11 at 19:19
@Tom: You need to look at it more carefully. You might think you're in a different folder than you actually are. Also, put the file in a folder, not in the root of the C: drive. –  Robert Harvey Feb 8 '11 at 19:21

As mention before you have a export tab for do things things. But if you want to export a tricky question or a very special ordering you can do as following:

Go to View or write your SQL question
In the bottom of the view-page you will have a Export link. 
If you click on that you will now export the question (and its order) 
in any format you chose
share|improve this answer

Your Answer


