Brkk
Brkk

Reputation: 607

Creating an independent copy of a MySQL database

When you dump the database 'A' using mysqldump and imported into 'A_test', would they be two independent copies of the same database? Or changes to one of them would also affect the other one?

Upvotes: 0

Views: 54

Answers (3)

Chezshire
Chezshire

Reputation: 713

You have two independent databases. Database 'A' AND you also have database 'A_test'. And quires made to one will not affect the other unless you reference both in the query itself. I.E. if you add an entry to 'A', it will not also be added to 'A_Test' unless you also add it to 'A_Test'.

Upvotes: 1

JPT
JPT

Reputation: 555

If you create any data in database B, then it is completely independent of database A. As far as I know, there is no way to connect tables of different databases in any way.

if you want to make sure nothing bad happens,

  • create a user B that only has access rights to database B.
  • Use user B to import the database into B.
  • Use user B to access database B from your app.

User B cannot change anything belonging to database A.

(you always should create user/database pairs with the same name)

Upvotes: 2

Alessandro Lai
Alessandro Lai

Reputation: 2274

No, they become two different identical database, and changes on one does not reflects on the other, after the dump and import procedure.

Upvotes: 2

Related Questions