View Full Version : phpmyadmin backup

12-25-2010, 04:09 AM
im trying to correct my auto database backup php script, i need the backups from the script to be just as if i did an export from myphpadmin. so all i have to do is import them..

i did a backup thru my php script and then i did another back up thru myphpadmin and i compared the sql files...

the difference i see is the header information, other than that its pretty much the same..

i dont expect anyone to do the work for me here. im just asking so that i can get a clear picture of the road ahead..

So question is, in order to make my php script create exactly the same as myphpadmin i would just simply have the php script write a similar header to the file..

the problem im having is that when i use a backup from y script im having to del the table and reacreate it, when i use the myphpadmin versi

is that pretty much in the ballpark ... or is it much more complicated

ok i thought i would show an example of the dif

here is the first part of my php script backup sql creation

CREATE DATABASE `xxxxxx_mastxx1`;

and here is the first part of the myphpadmin sql using export

-- phpMyAdmin SQL Dump
-- version 3.2.4
-- http://www.phpmyadmin.net
-- Host: localhost
-- Generation Time: Dec 24, 2010 at 06:48 PM
-- Server version: 5.1.46
-- PHP Version: 5.2.9


/*!40101 SET NAMES utf8 */;

-- Database: `xxxxxx_mastxx1`

-- --------------------------------------------------------

i see a dif in the create db vrs the myphpadmin that does not have that...

should i just go with the format of the myphpadmin version and have the php script follow that format

the problem im having is that when use the script version i have to delete the db first , when i use the myphpadmin version i dont have to i just import it as is and its great.

12-26-2010, 08:30 AM
Add to your script a DROP DATABASE IF EXISTS command at the top, that will drop it, then create it, then create all your tables, then fill them with data.


12-26-2010, 05:09 PM
thanks, when i used the import for the one created by my script it says drop database statements are disabled, and it does not say that when i import the one created by myphpadmin, thats why i was wondering if there was anything special in the myphpadmin sql file that i needed to add to my script sql creation..

update more info... just fyi im doing this from my admin panel, i have read that mysql wont let a user delete a database and thats why it does this, not sure if thats correct. but if i am in the admin panel i think i should be able to set a switch to let mysql know hey its me admin and not just some duffas trying to del my database..

is that what i need to do?

ok i think i found it, sorry fumigator i didnt realize you gave me that link, i assumed it was just a normal signature link.. lol ok after checking out the link, i found that mysqldump does not support drop database so what ill have to do is just leave the database alone and just drop the tables in it, i think it will support that.
if i can do that it should work i hope...

12-26-2010, 06:35 PM
that didnt work, wow they really do make this a huge pain in the *** to do dont they lol

12-26-2010, 09:36 PM
ok let me ask this.

this is in my myphpadmin sql


but it is not in my script sql version, i know i really dont need the engine and charset because they are set def by as a normal if i am correct.. but i would like to get the auto increment number in my dump..

i have been looking in mysql and i dont see the function.. do you know the function name..

or is it just better to not include any of those (engine, charset, auto_increment) in the sql that i create with my script ?

12-26-2010, 11:22 PM
i have been looking in mysql and i dont see the function.. do you know the function name..
You can get it from information_schema:


or is it just better to not include any of those (engine, charset, auto_increment) in the sql that i create with my script ?

You shouldn't have to include any of them, but it's good practice to.

12-27-2010, 01:23 AM
thanks Inigoesdr, i have been working most of the day to rewrite this thing and i have it so it pretty much resembles the same format and structure as the myphpadmin version.

with the exception of two things.

my key build for the multiple key is like this

$out .= " KEY $x (" . implode($columns, ",") . ")";

which the out put is: KEY lang (lang, key)

and it should look like this or it will bomb in error

KEY `lang` (`lang`,`key`)

so what i did was do this

$out .= " KEY $x (" . implode($columns, ",`") . "`)";

and that gets me closer to what i need

KEY lang (lang,`key`)

but whenever i try to put the "`" in any other place along that code string it bombs on me. besides i have some milti keys that this wont work on like.
KEY sales_id (sales_id, pid, uid) and it look like hell if i use that on it..

basically bottom line is im trying to create all multi keys $out in this format

key `xxx` (`xxx`,`xxx`) and if it has more
then use same format like key `xxx` (`xxx`,`xxx`, `xxx`)

and im starting with this

$out .= " KEY $x (" . implode($columns, ",") . ")";

which gives me the basic string, i just need to add the tildes..

and second thing is that when i import the myphpadmin sql
i get 57 queries as the completion result..

when i run my script sql i get 775 queries, should that concern me?

12-27-2010, 01:51 AM
ok i have the key build correctly but still have a query question

for anyone interested the out looks like this

$out .= " KEY $x (`". implode($mycols, "`,`") . "`)";
which gives you this format

KEY `lang` (`lang`,`key`)

whewww im glad thats done... i still have a question regarding the dif in the number of query completion i get when i run the two dif sql, not sure if i should be concerned with that..