2

I want to export some tables in my DB to an Excel/Spreadsheet every month. In PHPMyAdmin there is a direct option of exporting the result of a query to the desired filetype. How do I make use of this export feature without another script to run a cronjob on a monthly basis?

Basically on a CPanel (the DB is hosted in the web) we just have to give the path to the script to be executed via a cronjob. But in PHPMyAdmin there is no such opportunity. Its an included feature of PHPMyAdmin where we generally click and do it mannually. So how do i do it in Cpanel?

Stephan Weinhold
  • 1,623
  • 1
  • 28
  • 37
Nirmik
  • 87
  • 3
  • 15

3 Answers3

3

Do you have ssh access to the box? Personally I'd implement this outside of phpmyadmin, as phpmyadmin is just intended for manual operations via the interface. Why not write a simple script to export the db?

Something like mysqldump database table.

Autonomy
  • 402
  • 4
  • 13
2

Being a web-app, the export function is a POST request. In the demo application the URL is http://demo.phpmyadmin.net/STABLE/export.php, and then the post data contains all the required parameters, for example: (You can use Fiddler/Chrome dev tools too view it)

token:3162d3b849cf652c2577a45f90022df7
export_type:server
export_method:quick
quick_or_custom:custom
output_format:sendit
filename_template:@SERVER@
remember_template:on
charset_of_file:utf-8
compression:none
what:excel
codegen_structure_or_data:data
codegen_format:0
csv_separator:,
csv_enclosed:"
.....

The one tricky bit is the authentication token, but I believe this is also possible to overcome using some configuration and/or extract parameters (like the 'direct login' in http://demo.phpmyadmin.net/)

See here How to send data using curl from Linux command line?

If you want to avoid all this, there are many other web-automation tools that can record the scenario and play it back.

Community
  • 1
  • 1
Yasei No Umi
  • 1,574
  • 9
  • 23
2

just write a simple php script to connect to your database and use the answer here:

How to output MySQL query results in CSV format?

Community
  • 1
  • 1
WebChemist
  • 4,393
  • 6
  • 28
  • 37
  • ok you may have some permission issues on this... works fine on my home wamp server but my work's cpanel site gave me denied me access when I tried to use outfile. – WebChemist Jul 18 '12 at 08:08