Jump to content


Duplicate Mysql Db Not Backup And Restore

  • Please log in to reply
2 replies to this topic

#1 cleary1981

  • Members
  • PipPipPip
  • Advanced Member
  • 210 posts
  • LocationIreland

Posted 05 December 2012 - 04:04 PM

Apologies if this sounds stupid, it's been a while since I have done any development.

I have a site hosted on 1and1 server connected to a DB. I have copied the whole site into a sub directory to make changes to the code. I want to make a new DB with all the same data as my Live site. When I export the data using phpmyadmin and import it just overwrites the existing DB.

Is there a way I can export my DB and then rename it so when I upload it I have two databases?

Thanks in advance.

#2 PFMaBiSmAd

  • Staff Alumni
  • Advanced Member
  • 16,767 posts
  • LocationColorado, U.S.A.

Posted 05 December 2012 - 04:11 PM

In your .sql backup file, there are lines like -

USE db_name;

Just enter a new name for the db_name.

You will also need to assign a database user permissions to use that new database.
Signature: (not a comment about anything you posted unless specifically indicated)
Debugging step #1: To get past the garbage-out equals garbage-in stage in your code, you must check that the inputs to your code are what you expect.

Programming is just problem solving, but it is done in another language. You must learn enough of the programming language you are using to be able to read and write code.

#3 Psycho

  • Moderators
  • Advanced Member
  • 11,822 posts
  • LocationCanada

Posted 05 December 2012 - 05:22 PM

Aside from your question I would add the following advice:

Instead of copying the files into a subfolder I would advise creating a new top level directory, copy all your files there, and then create a sub-domain for your development environment, e.g. dev.mydomain.com.

If you have any file paths in the PHP or HTML that is relative to the root of the web root or the URL you will run into errors if just running from a sub-folder. But, then again, if your intent is to modify the site to work from sub-folders then you would want to do that.
The quality of the responses received is directly proportional to the quality of the question asked.

I do not always test the code I provide, so there may be some syntax errors. In 99% of all cases I found the solution to your problem here: http://www.php.net

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users