My production database currently contains 4k MyModels (loaded from the dev database last year). I started working on this project again. I now have 270k MyModels (including the original 4k MyModels). I want to export this new datadump to my production database. What will happen to the 4k MyModels already there (doing a simple dumpdata/loaddata)? How will the records be overwritten?
-
Well you will overwrite them, why would you do this? – copser Jun 02 '17 at 03:38
-
How else would I get 270k models from my dev server to my production server – Mike Johnson Jr Jun 02 '17 at 03:50
-
If I understand this correctly you want to transfer your database data from development database to a production database? – copser Jun 02 '17 at 03:57
-
Yes, 270k records from dev to prod with dumpdata/loaddata – Mike Johnson Jr Jun 02 '17 at 04:02
-
Ok now you see I have a problem, with that, I don't know why you want o do that to your production database, it should go the other way around, you should dump/load data from your production to your dev db – copser Jun 02 '17 at 04:05
1 Answers
After you dump your data into a file, you go and cd into folder where you keep your dump file and do
mysql -u root -p your_database_name < DumpDevDatabase.sql
NOTE:
Bare in mind that you will create new database in production every time you want to dump your data into it and that is a bad thing.
You should not do this, this should work the other way around, Production database need to be isolated from this things, you should dump data from your production to your development database so you can work with the data.
In that case when you dump data from production to development, again you need to create new database for loading data into it.
You can use tools like mysql workbench or pgadmin if you use postgreql, this will help you to easier work with your database.
I'm still not sure why you want to do it, but I strongly advice you not do overwrite your production database.

- 2,523
- 5
- 38
- 73