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
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.
- 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)?
Use MySQL's mysqldump command line utility. Run the following command on on shell mysqldump db_name > dbname.sql Code (markup):
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.
This approach does not work for InnoDB tables. The safest way is to use mysqldump command line utility. Otherwise use navicat as jestep suggested.
<?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.