How to duplicate a database?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • glenn
    Junior Member
    • Apr 2004
    • 18

    #1

    How to duplicate a database?

    Hi folks,

    In the next few days I will be needing to duplicate a forum database. This is so I can convert the database over to use a different forum and I want to run it on a completely seperate database. Is there a simple and easy way to do this?

    In the past I have exported the database and downloaded it to my desktop machine with phpmyadmin then created a new database and run all the sql queries in blocks because phpmyadmin times out when trying to do the whole .sql file at once. This takes a large amount of time.

    Can the queries be run from the .sql file sitting locally on the server? How is this acheived?

    Surely there is a quick and easy way to duplicate an existing database?
    Any suggestion would be appreciated.
  • sdjl
    Senior Member
    • Mar 2004
    • 502

    #2
    There is an easy way to download the database to your webspace.
    You need to have SSH enabled on the account.

    All you do is then login through your SSH terminal window.
    Navigate to where you want to store the .sql file, like so:

    cd public_html/folder

    Then login to MySQL like so:

    mysql -u USERNAME-HERE -p -D DATABASENAME-HERE > database_backup.sql

    You'll then be prompted for your MySQL database password. It may look like the terminal window has frozen depending how large your database is. Your database should now be located under public_html/folder with a file name of database_backup.sql

    Now to get the file contents into a new database.
    From the same window (i.e. you haven't logged out and you're still under the folder you saved the .sql file to!) type the following, again changing details to yours:

    mysql -u USERNAME-HERE -p -D NEW_DATABASENAME-HERE < database_backup.sql

    It will ask for your password again. All should be done

    David
    -----
    Do you fear the obsolescence of the metanarrative apparatus of legitimation?

    Comment

    • james
      Senior Member
      • Mar 2004
      • 183

      #3
      What David said is how I was going to suggest you did it.

      Don't forget to create the new database in cpanel before you try and dump the contents of the old database into it!

      James

      Comment

      • glenn
        Junior Member
        • Apr 2004
        • 18

        #4
        Thanks everyone,

        worked a treat. Saved me a reasonable amount of time :-)

        Comment

        Working...