Thursday 4 December 2008

mysql database copy

problem: its always good to have a dev version of any working database for learning purposes...

what im not doing: going all 'gui'... the command line rox and it all starts there


this is surprisingly difficult with my set-up. xampplite setup on a xppro box (its my work setup, dont judge me)! in the end i had to do the following;

create database test;

then export my production database to file via phpMyAdmin, .sql

then i seemed to hit a brick wall. found posts that advised adding 'use test;' at the top of the file then issuing the following command;

mysql < c:/backup.sql;

wouldnt work. tried;

mysql -u root -p ***** < c:/backup.sql;

no good :(

but then, almost as a last gasp;

use test;
source c:/backup.sql;

job done! always remember '\' escapes in mysql so windows absolute paths are initially annoying!