MYSQLDIFF(1)
π NAME π
mysqldiff(1) β omg bestie, it compares MySQL database schemas. This is the MYSQLDIFF(1) page from User Contributed Perl Documentation, and yes itβs giving βschema diff but make it Perlβ π
β¨
π¦ SYNOPSIS π¦
mysqldiff [B<options>] B<database1> B<database2>
mysqldiff --help
πΈ DESCRIPTION πΈ
Okay so mysqldiff is a Perl script front-end to the CPAN (http://www.perl.com/CPAN) module MySQL::Diff (http://search.cpan.org/search?module=MySQL::Diff). It compares the data structures (i.e. schema / table definitions) of two MySQL (http://www.mysql.com/) databases, and returns the differences as a sequence of MySQL commands suitable for piping into mysql which will transform the structure of the first database to be identical to that of the second (c.f. diff and patch). Slay.
Database structures can be compared whether they are files containing table definitions or existing databases, local or remote. Love that for us.
N.B. the program makes no attempt to compare any of the data which may be stored in the databases. It is purely for comparing the table definitions. The author has no plans to implement data comparison; it is a complex problem and thereβs no need of such functionality anyway. However there is another programcoldiff(http://rossbeyer.net/software/mysql_coldiff/) which does this, and is based on an older program calleddatadiffwhich seems to have vanished off the βnet. RIP.
For PostgreSQL there are similar tools such as pgdiff (http://pgdiff.sourceforge.net/) and apgdiff (http://apgdiff.startnet.biz/).
π₯ EXAMPLES π₯
# compare table definitions in two files
mysqldiff db1.mysql db2.mysql
# compare table definitions in a file 'db1.mysql' with a database 'db2'
mysqldiff db1.mysql db2
# interactively upgrade schema of database 'db1' to be like the
# schema described in the file 'db2.mysql'
mysqldiff -A db1 db2.mysql
# compare table definitions in two databases on a remote machine
mysqldiff --host=remote.host.com --user=myaccount db1 db2
# compare table definitions in a local database 'foo' with a
# database 'bar' on a remote machine, when a file foo already
# exists in the current directory
mysqldiff --host2=remote.host.com --password=secret db:foo bar
β¨ OPTIONS β¨
-?,--helpβ show usage-A,--applyβ interactively patchdatabase1to matchdatabase2-B,--batch-applyβ non-interactively patchdatabase1to matchdatabase2-d,--debug[=N]β enable debugging [levelN, default1]-l,--list-tablesβ output the list off all used tables-o,--only-bothβ only output changes for tables in both databases-k,--keep-old-tablesβ donβt outputDROP TABLEcommands-c,--keep-old-columnsβ donβt outputDROP COLUMNcommands-n,--no-old-defsβ suppress comments describing old definitions-t,--table-re=REGEXPβ restrict comparisons to tables matchingREGEXP-i,--tolerantβ ignoreDEFAULT,AUTO_INCREMENT,COLLATE, and formatting changes-S,--single-transactionβ perform DB dump in transaction For more info see:http://dev.mysql.com/doc/refman/en/mysqldump.html#option_mysqldump_single-transaction-h,--host=[hostname]β connect to host-P,--port=[port]β use this port for connection-u,--user=[user]β user for login if not current user-p,--password[=password]β password to use when connecting to server-s,--socket=...β socket to use when connecting to server
π For <databaseN> only, where N == 1 or 2 π
--hostN=[hostN]β connect to host--portN=[portN]β use this port for connection--userN=[userN]β user for login if not current user--passwordN[=passwordN]β password to use when connecting to server--socketN=[socketN]β socket to use when connecting to server
π§ INTERNALS π§
For both of the database structures being compared, the following happens:
- If the argument is a valid filename, the file is used to create a temporary database which
mysqldump -dis run on to obtain the table definitions in canonicalised form. The temporary database is then dropped. (The temporary database is namedtest_mysqldiff_temp_somethingbecause default MySQL permissions allow anyone to create databases beginning with the prefixtest_.) - If the argument is a database,
mysqldump -dis run directly on it. - Where authentication is required, the hostname, username, and password given by the corresponding options are used (type
mysqldiff --helpfor more information). - Each set of table definitions is now parsed into tables, and fields and index keys within those tables; these are compared, and the differences outputted in the form of MySQL statements.
π BUGS, DEVELOPMENT, CONTRIBUTING π
See http://adamspiers.org/computing/mysqldiff/.
π COPYRIGHT AND LICENSE π
Copyright (c) 2000-2016 Adam Spiers. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
π SEE ALSO π
MySQL::Diff, MySQL::Diff::Database, MySQL::Diff::Table, MySQL::Diff::Utils, mysql, mysqldump, mysqlshow
π AUTHOR π
Adam Spiers β mysqldiff@adamspiers.org
okay bye bestie! this is MYSQLDIFF(1), made by perl v5.42.3, dated 2018-06-05 β mwah πβ¨
π¦ where this page comes from
- nixos 26.05: perl5.42.3-MySQL-Diff 0.60
- nixpkgs unstable: perl5.42.3-MySQL-Diff 0.60
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms