Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Migrate a Development MySQL database to a Production database

I need to be able to make changes to my development DB, Such as adding a table or so adding a column.

Is it possible to take this new DB schema and merge it or diff-&-merge it with the production DB without having to rebuild/repopulate the production database?

any tips welcome.

like image 813
madmaze Avatar asked Dec 13 '10 23:12

madmaze


People also ask

How do I transfer data from one MySQL database to another?

To copy a MySQL database from a server to another, you use the following steps: Export the database on the source server to a SQL dump file. Copy the SQL dump file to the destination server. Import the SQL dump file to the destination server.

Can you transfer MySQL database?

In cases where you need to transfer databases between different architectures, you can use mysqldump to create a file containing SQL statements. You can then transfer the file to the other machine and feed it as input to the mysql client. Use mysqldump --help to see what options are available.

Can I use MySQL for production?

The short answer: Yes it is safe for production use and nearly everyone uses the community version.


1 Answers

A simple way to do this is to keep track of your ALTER's and CREATE's in a file.

For example, if I were to add a column to a table on the development db, I would copy paste the sql I used into a file called migrate.sql. I would keep doing this until I'm ready to migrate to production.

At this point the file would be a series of sql statements that could be run in order on the production db to "sync" it with the development environment.

If you're not writing the raw queries yourself, you can probably get the commands being run out of whatever GUI tool you're using.

like image 186
lzhang Avatar answered Sep 23 '22 23:09

lzhang