Synchronizing tables on 2 MySQL servers - mysql

I have 2 MySQL servers: one for development, other for production. Both contain same table structure, but different data on tables.
When I have done change on dev server, like add column to table, I have manually made the same change later to production server. But this slow and error prone, especially if there are many changes to be made at once.
Is there better way to do this? I have phpMyAdmin, maybe that has some neat trick?
Also, is there a dedicated term for what this process is called? Searching for 'table update' or similar does not yield results on this topic.
EDIT:
Forgot to mention that I am using Windows.
So apparently I need some kind of diff tool for this. I haven't tested all of these proposed software yet, but so far they seem very useful.

I've used Red Gate's SQL Compare before for SQL Server; this is their MySQL product. I don't have the budget to buy it myself, but if it works anything like SQL Compare did, it'll do exactly what you want it to do.

When ever I do this I have used the data or structure sync in a Mysql GUI app called Navicat, there is a free version available and it does what you asked perfectley.

Try to compare and synchronize databases with schema/data comparers in dbForge Studio for MySQL.

Related

How to compare/update two mySQL databases' schema

Okay, I've got two databases, the second one being a more up to date version of the first one. It has new columns, tables, constraints, and whatnot.
I was wondering if there is a solid program out there that will update the first database with all that of the second already updated database (Not the data, just the tables, columns and all that) or am I stuck creating my own update script from scratch?
I actually found another post, that did not look like the same thing but it still helped me anyway, I found a program called Toad for MySQL and it has a compare Schema option that compares the two databases and then can sync one to the other (it creates a script and executes it) it seems to be working flawlessly, but I'm still testing the web app that uses the database to ensure this is true.
If you're on Windows, the RedGate SQL data and schema compare tools are beautiful:
http://mysql-compare.com/info
I've used them a few times. They're quite simple to use.
They're designed around creating DB diffs for moving from dev/QA/staging environments to integration/production environments (so yes, they generate scripts).
If you are looking for a tool that will compare at the schema level then I would suggest Navicat. The older version that I use works well for getting my production and development boxes in synch. I don't recommend it for large levels of data synchronization though - it seems very slow compared to a SQL dump and SQL import.

Compare database differences and get SQL output

I need ability to compare two similar databases. One will be slightly newer than the other and have changes to the structure of the database as well as possibly the content within it.
So far I have tried using liquibase but it doesn't seem to be comparing properly.
I have also tried the MySQL Diff Perl module which works but doesn't consider content.
Main Question:
Does anyone know any solutions that will give back SQL for both structural and content differences and generate a SQL script?
A bit more info:
The intended use for this is when making updates and installing MODs to phpBB so that the forum can be included in the build process along with the rest of our website. Which has a 4 tier process (local, development, staging, production).
When installing the phpBB updates and MODs I will make a dump of the current production database and lock the site so no new data can be added whilst I make changes. That way databases shouldn't come out of sync.
When installing MODs and updates sometimes the database structure changes and also the data within tables, especially when adding things requiring extra permissions etc.
The solution I use therefore will be used to compare the local database with the upgraded changes to the production database, providing me with a script I can run on each tier in the build process, rather than manually installing the update/MOD on each.
You can use SQLyog Database synchronization tool to sync two databases,either one-way or two-way. By far this is the best data comparison tool for MySQL GUI. And, Schema sync for schema comparisons between two databases.
Both tools can generate SQL scripts.
I've actually found a way to do it via Navicat for MySQL using the Tools > Structure Syncronization option.
This will give SQL statements for differences in structure between the two databases.
Then do do the data differences you can use Data Syncornization.
I've managed to copy out the SQL script for differences in structure. However the data syncronization seems to be more of an internal Navicat thing. I'm sure there's a way that the queries could be extracted though.
Please note I'm using a license version so not sure if its available in the free to use one.

A Database Tool to check changes happened overnight and upload to MasterDB

HI
I have 5 different database and a Master DB with same Schema .I am looking for a tool which can check any changes( new row insertion ) has happened since my last update and Sync with my Master DB . Is there any tool available for this
Sounds like a good case for using merge replication.
Don't know about free tools - but I know of the redgate's data compare which will do this job for you. It's automatable. Having used it for this task I'd strongly recommend it.
As a personal solution, since you're using SQL Server you could iterate the tables (sys.tables), and do an join between DBs and see what needs to be inserted/deleted etc. Sounds like a tedious job though if you reuse Keys. If the keys are not reused then the task is quite simple.

MySQL Version Control

I am wanting to do some basic version control with my mysql database structure. I am not worried about the contents of the database, I just want to track any new tables added, tables altered, and tables deleted.
Is there a simple application that could do this all automagically? (Needs to run on a Linux envirnment)
I have looked at a few, such as PHPMyVersion, but it is no longer being developed, and not quite what I was looking for.
Thanks
Maybe something like MySQLdiff is what you want.

How to synchronize development and production database

Do you know any applications to synchronize two databases - during development sometimes it's required to add one or two table rows or new table or column.
Usually I write every sql statement in some file and during uploading path I evecute those lines on my production database (earlier backing it up).
I work with mySQL and postreSQL databases.
What is your practise and what applications helps you in that.
You asked for a tool or application answer, but what you really need is a a process answer. The underlying theme here is that you should be versioning your database DDL (and DML, when needed) and providing change scripts to be able to update any version of your database to a higher version.
This set of links provided by Jeff Atwood and written by K. Scott Allen explain in detail what this ought to look like - and they do it better than I can possibly write up here: http://www.codinghorror.com/blog/2008/02/get-your-database-under-version-control.html
For PostgreSQL you could use Another PostgreSQL Diff Tool . It can diff two SQL Dumps very fast (a few seconds on a db with about 300 tables, 50 views and 500 stored procedures). So you can find your changes easily and get a sql diff which you can execute.
From the APGDiff Page:
Another PostgreSQL Diff Tool is simple PostgreSQL diff tool that is useful for schema upgrades. The tool compares two schema dump files and creates output file that is (after some hand-made modifications) suitable for upgrade of old schema.
Have scripts (under source control of course) that you only ever add to the bottom off. That combined with regular restores from your production database to dev you should be golden. If you are strict about it, this works very well.
Otherwise I know lots of people use redgate stuff for SQLServer.
Another vote for RedGate SQL Compare
http://www.red-gate.com/products/SQL_Compare/index.htm
Wouldn't want to live without it!
Edit: Sorry, it seems this is only for SQL Server. Still - if any SQL Server users have the same question I'd definitely recommend this tool.
If you write your SQL statements for your development database (which are, I imagine, series of DDL instructions such as CREATE, ALTER and DROP), why don't you keep track of them by recording them in a table, with a "version" index? You will then be able to:
track your version changes
make a small routine allowing the "automatic" update of your production database by sending the recorded instructions to the database.
I really like the EMS tools.
There tools are available for all popular DB's and you have the same user experience for every type of DB.
One of the tools is the DB Comparer.
TOAD
saved many an ass several times in the past. Why do people run sql with no exit strategy?
the redgate one is good also.
Siebel (CRM, Sales, etc. management product) has a built-in tool to align the production database with the development one (dev2prod).
Otherwise, you've got to stick with manually executed scripts.
Navicat has a structure synchronisation wizard that handles this.
I solve this by using Hibernate. It can detect and autocreate missing tables, columns, etc.
You could add some automation to your current way of doing things by using dbDeploy or a similar script. This will allow you to keep track of your schema changes and to upgrade/rollback your schema as you see fit.
Here's a straight linux bash script I wrote for syncing Magento databases... but you can easily modify it for other uses :)
http://markshust.com/2011/09/08/syncing-magento-instance-production-development
DBV - "Database version control, made easy!" (PHP)