Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying a DB 1

Status
Not open for further replies.

hermes1

Programmer
Oct 22, 2003
38
US
Ok i know this is easy but i have only used mySQL on a limited basis and if things got messed up it would be real bad. But basically i want to duplicate a database in mySQL just the structure with no data in phpmyadmin.
 
There might be an easier way than the one I'm about to suggest but it probably depends on your permissions within phpmyadmin.

On the main page once you have logged into phpmyadmin, click on 'Export.'

Then highlight the database whose structure you want to copy. Choose 'SQL' underneath that. Then make sure that ONLY 'Structure' checkbox is checked. If anything else is, then uncheck it...especially 'Data.' Click 'Go.'

The output should be valid SQL for you to copy and paste into the SQL textbox on the SQL tab. Before doing so, however, in the output that was generated make sure you change the name of the database you copied to the name you want the new one to have. Example would be if your existing database was called old_db, then:

CREATE DATABASE `old_db`;
USE old_db;

Should now be:

CREATE DATABASE `new_db`;
USE new_db;

Sorry this got so long...
 
If you'd like to schedule this on an ongoing basis with or without data, use mysqlhotcopy. Works great. I backup some of my databases hourly.

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top