Tuesday, March 1, 2011

Copy a table/database from old table/database in MySQL


Copy a table from old table in MySQL
1) First:
creates the new table mytable_new by duplicating the structure of the existing table
in a database such as mydb:
Code:
CREATE TABLE mytable_new LIKE  mydb.mytable;


2) Copy the data from old to new.
Code:
INSERT mytable_new SELECT * FROM  mydb.mytable;



Copy a database from old database in MySQL
The reference using command line can be found:
http://www.keithjbrown.co.uk/vworks/mysql/mysql_p6.php
I used MySQL Query Browser

1) Go to Tools ->MySQL Administrator
2) Click backup->New Poject->Save Project->Excute Backup now
3) Click Restore->Open backup file (file from step 2), choose another schema
click "start restore"
4) Click user under user account under MySQL Administrator, assign (add) privileges of new database for this user

No comments:

Post a Comment