Export a 3GB MySQL database (standard phpMyAdmin won't let me!)

Discussion in 'MySQL' started by PJB, Mar 5, 2010.

  1. #1
    Hi,

    I'm looking to export a MySQL database from my local machine (going to completely reinstall Windows on it).

    Its over 3GB in size - but when I export it via phpMyAdmin (I assume this is what I need to do to back it up?) it seems to "finish" exporting exactly after 5 minutes - is there a way to fix this?

    Thanks
     
    Last edited: Mar 5, 2010
    PJB, Mar 5, 2010 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    I use navicat for stuff like this. You can also do it command line. phpmyadmin wont be able to support backups and restores of this size. You either need to get an separate program to do it, or use one of the command line mysql tools to do it.
     
    jestep, Mar 5, 2010 IP
  3. PJB

    PJB Peon

    Messages:
    60
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    - thanks jestep,

    Sorry if this is a daft question, but how do you do it via the command line (have never done it his way, sorry)?
     
    PJB, Mar 5, 2010 IP
  4. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #4
    Use MySQL's mysqldump command line utility. Run the following command on on shell

    mysqldump db_name > dbname.sql
    Code (markup):
     
    mwasif, Mar 5, 2010 IP
  5. Guttu

    Guttu Peon

    Messages:
    728
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    0
    #5
    You can copy the raw database file from "data" folder of your mysql installation. Thats the easiest way. The database is stored in a folder named with the dbname in "data" folder.
     
    Guttu, Mar 10, 2010 IP
  6. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #6
    This approach does not work for InnoDB tables. The safest way is to use mysqldump command line utility. Otherwise use navicat as jestep suggested.
     
    mwasif, Mar 25, 2010 IP
  7. EfSaNe

    EfSaNe Member

    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #7
    
    <?php
    
    ob_start();
    
    $username = "";
    $password = "";
    $hostname = "localhost";
    $sConnString = mysql_connect($hostname, $username, $password)
    or die("Unable to connect to MySQL");
    
    //create a connection object
    $connection = mysql_select_db("dbname",$sConnString)
    or die("Could not select DB");
    
    $command = "mysqldump --add-drop-table --host=localhost --user='' --password='' dbname";
    system($command);
    
    $dump = ob_get_contents();
    ob_end_clean();
    
    //The database dump now exists in the $dump variable... write it to a file using...
    
    $fp = fopen("dump.sql", "w");
    fputs($fp, $dump);
    fclose($fp);
    
    ?> 
    
    Code (markup):
    edited username and pasword, upload your host and running php script.
     
    EfSaNe, Mar 26, 2010 IP