开发者

Keep MySQL schema in sync between computers

开发者 https://www.devze.com 2023-03-10 17:14 出处:网络
When developing, I can use SVN or Git to keep code in sync开发者_高级运维 between machines. However, I have been unable to find something similar for MySQL. Does anyone know of anything?

When developing, I can use SVN or Git to keep code in sync开发者_高级运维 between machines. However, I have been unable to find something similar for MySQL. Does anyone know of anything?

Update: I am trying to get the schema changes across machines. Getting the data to sync as well would be great but is not as important at the moment.


Data is not considered a part of your "application source". The schema (ie definition of the tables, indexes etc) should be considered part of your source, although many people do not bother when it comes to MySQL.

If you need to keep data syncronised, you should look at replication scenarios.

See this about replication for MySQL


MySQL Replication

  • How to Set Up Replication


Unless you want to use replication (haven't dealt with this with MySQL before, personally), you're better off using some sort of script to do a mysqldump and commit the backup each time.

You might even be able do it with a git hook to have it automatically dump it out and commit it before a push.


MySQL Replication is the way to go here.

Keep an eye on the data both sides of replication as MySQL doesn't offer synchronous replication (yet).

There's a comprehensive toolset to monitor your replication (and more) called Maatkit. This allows you to compare checksums of your data and sync if there are discrepancies.


https://github.com/reduardo7/db-version-updater

Script to keep the verion of the database model updated, using a simple Linux script.

This script creates an auxiliar Database Table to register the executed scripts, and prevent to execute any executed script.

--

https://github.com/reduardo7/db-version-updater-mysql

Keep the verion of the database model updated, using a MySQL script.

With this script, you can keep the version of the database model without needing another tool than MySQL console.

It is the simplest and easiest way to perform this task so common, without the need to using other extra tools.

To work, creates an auxiliar database table (database_version) to register the executed scripts, and prevent to execute any executed script.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号