Page 1 of 1
How do I run a 'save as' script to export database?
Posted: Thu Oct 13, 2016 2:47 am
by simonmlewis
We have backups of our websites, but I would like to be able to click a button in our own CMS that saves either some fundamental tables, or ALL tables. So it basically does what the phpmyadmin 'export' to .sql does.
How does one go about that?
Re: How do I run a 'save as' script to export database?
Posted: Thu Oct 13, 2016 7:04 am
by Celauran
You can't stick with mysqldump at the command line? Or a manual export when you need one?
Code: Select all
So it basically does what the phpmyadmin 'export' to .sql does.
phpMyAdmin is written in PHP. Have you taken a look at how they do it?
Re: How do I run a 'save as' script to export database?
Posted: Thu Oct 13, 2016 7:11 am
by simonmlewis
I can login to the control panel system, and go thru the various buttons to get there - but we regularly work in the CMS for the website so I wondered if I could do it from there instead.
I don't quite know where in phpmyadmin that code would be. But I figured there would be an easy way to do it anyway.
Re: How do I run a 'save as' script to export database?
Posted: Thu Oct 13, 2016 7:14 am
by Celauran
You basically need the schema definitions, SELECT * from each table, and write to file. What have you tried so far?
Re: How do I run a 'save as' script to export database?
Posted: Thu Oct 13, 2016 7:21 am
by simonmlewis
I Tried this simple query:
Code: Select all
<?php
include "dbconn.php";
mysql_query("SELECT * FROM products INTO OUTFILE '/tmp/products.sql'");
echo "yes";
?>