Here you will find a simple drop-in PHP script that helps you to export data from MySQL database to multiple CSV files, one CSV file per table.

To use it, first upload this script to your server:


This script, in your server, should be accessible from web. For example, you could request it like this:


Next, you need to write configuration file, that looks like this:

dsn: mysql://user:pass@localhost/dbname
statefile: opendataexport.state
outputdir: output

table1: id

table2: id

Place this file next to opendataexport.php and give it opendataexport.cfg name. In this configuration file, all paths are relative to opendataexport.php script.

id specified in table1: id and table2: id is a column name, that is used to order table rows and to track export state. When you call export script repeatedly, it reads statefile and continues export from where it was finished last time. So this part is important and you need to specify an unique and incrementing column. Instead of primary key you can also use a column that contains date and time, when this record was created.

Also, make sure, that opendataexport.cfg configuration file is not visible from web, because it contains database connection credentials.

That's it! Now, if you will access this script from web, CSV files will be generated to outputdir directory.