The following steps are meant to capture a snapshot of your development database structure and your staging/production database structure, compare the two, and provide SQL to consolidate the differences.
This article relates to one of many methods for database version control in a singular or team-based environment.
MySQL Workbench
Having MySQL Workbench is not mandatory for this process. But it’s a nice interface to consolidate the suite of tools that MySQL offers.
The available MySQL Utilities programs can be seen in the console output below with the “help” command executed.
1234567891011121314151617181920212223242526
~$ mysqluc -e "help utilities"
Launching console ...
Utility Description
---------------- ---------------------------------------------------------
mysqlauditadmin audit log maintenance utility
mysqlauditgrep audit log search utility
mysqldbcompare compare databases for consistency
mysqldbcopy copy databases from one server to another
mysqldbexport export metadata and data from databases
mysqldbimport import metadata and data from files
mysqldiff compare object definitions among objects where the
difference is how db1.obj1 differs from db2.obj2
mysqldiskusage show disk usage for databases
mysqlfailover automatic replication health monitoring and failover
mysqlfrm show CREATE TABLE from .frm files
mysqlindexcheck check for duplicate or redundant indexes
mysqlmetagrep search metadata
mysqlprocgrep search process information
mysqlreplicate establish replication with a master
mysqlrpladmin administration utility for MySQL replication
mysqlrplcheck check replication
mysqlrplshow show slaves attached to a master
mysqlserverclone start another instance of a running server
mysqlserverinfo show server information
mysqluserclone clone a MySQL user account to one or more new users
The same can be done by entering mysqluc -e "help utilities" into your console.
If you receive the following error.
123456
Traceback (most recent call last):
File "/bin/mysqluc", line 23, in <module>
from mysql.utilities.common.options import license_callback, UtilitiesParser
File "/Library/Python/2.7/site-packages/mysql/utilities/common/options.py", line 34, in <module>
from mysql.connector.conversion import MySQLConverter
ImportError: No module named connector.conversion
ImportError: No module named connector.conversion
MySQL Utilities assumes that the MySQL Connector for Python has been installed.