Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,467
    Thanks
    278
    Thanked 32 Times in 31 Posts

    phpmyadmin backup

    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

    Code:
    CREATE DATABASE `xxxxxx_mastxx1`;
    CREATE TABLE
    and here is the first part of the myphpadmin sql using export

    Code:
    -- 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
    
    SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
    
    
    /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
    /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
    /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
    /*!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.
    Last edited by durangod; 12-25-2010 at 04:32 AM.

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    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.

    http://dev.mysql.com/doc/refman/5.0/...-database.html

  • #3
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,467
    Thanks
    278
    Thanked 32 Times in 31 Posts
    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...
    Last edited by durangod; 12-26-2010 at 05:26 PM. Reason: another update

  • #4
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,467
    Thanks
    278
    Thanked 32 Times in 31 Posts
    that didnt work, wow they really do make this a huge pain in the *** to do dont they lol

  • #5
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,467
    Thanks
    278
    Thanked 32 Times in 31 Posts
    ok let me ask this.

    this is in my myphpadmin sql

    Code:
    ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
    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 ?

  • #6
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    Quote Originally Posted by durangod View Post
    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:
    Code:
    SELECT `AUTO_INCREMENT` FROM `information_schema`.`TABLES` WHERE `TABLE_NAME` = 'log'
    Quote Originally Posted by durangod View Post
    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.

  • #7
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,467
    Thanks
    278
    Thanked 32 Times in 31 Posts
    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

    Code:
    $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

    Code:
    $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

    Code:
    $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?

  • #8
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,467
    Thanks
    278
    Thanked 32 Times in 31 Posts
    ok i have the key build correctly but still have a query question

    for anyone interested the out looks like this

    Code:
    $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..


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •