Saturday, March 30, 2013

Determine differences between two MySQL databases

mysqldump --skip-comments --no-data -u your_user1 -p your_database_name1 > file_1.sql
mysqldump --skip-comments --no-data -u your_user2 -p your_database_name2 > file_2.sql
diff file_1.sql file_2.sql
Note that the first two lines may end up being identical except for the .sql file name at the end of the command (because databases that you want to compare often exist in independent environments). For example, you might run the first command locally and the second on a remote dev machine. In both instances your user may be root and your database name might be the name of your project. If you run the first command on your local machine and the second on a remote, you'll have to scp file_2.sql to your local machine before running the diff command. Enjoy!

No comments:

Post a Comment