Showing posts with label MySQL utility. Show all posts
Showing posts with label MySQL utility. Show all posts

March 24, 2022

MySQL mysqldbcompare utility

mysqldbcompare utility commands in MySQL

mysqldbcompare    compare databases for consistency

Usage: mysqldbcompare --server1=user:password@host:port:socket --server2=user:password@host:port:socket db1:db2

mysql db compare command-line utility, in MySQL, compares the objects and/or data from two MySQL databases to find differences, objects having different definitions and/or data in the two databases.

mysqldbcompare --help
mysqldbcompare --version

mysqldbcompare --server1=host1 --server2=host2 proddb1:proddb2 --run-all-tests
mysqldbcompare --run-all-tests --server1=host1 --server2=host2 proddb:proddb --changes-for=server1
mysqldbcompare --run-all-tests --server1=host1 --server2=host2 proddb1:proddb2 --changes-for=server1 --disable-binary-logging

mysqldbcompare --run-all-tests --server1=root@host1 --server2=root@host2 proddb --changes-for=server1 --disable-binary-logging
mysqldbcompare --server1=host1 --server2=host2 proddb --run-all-tests --changes-for=server1 --disable-binary-logging -a --format=csv
mysqldbcompare --run-all-tests --server1=localhost --server2=remotehost $DATABASE:$DATABASE --changes-for=server2 --disable-binary-logging -a --difftype=context

mysqldbcompare --server1=root:password@localhost:3306 --server2=root:password@localhost:3306 testdb:devdb --run-all-tests --skip-data-check
mysqldbcompare --run-all-tests --server1=master_host --server2=slave_host testdb:testdb --changes-for=server1 --disable-binary-logging --skip-table-options --difftype=sql

mysqldbcompare --run-all-tests --server1=`hostname` --login-path=rhost --server2=dba_login_path --changes-for=server2 --disable-binary-logging --difftype=sql   mysql_db_compare_log.log
mysqldbcompare --run-all-tests --skip-diff --server1=localhost --server2=rhost --changes-for=server2 --disable-binary-logging --difftype=differ devdb
mysqldbcompare --server1=${USER}:${PASS_WORD}@${HOST1}:3310 --server2=${USER}:${PASS_WORD}@${HOST2}:3310 ${DB}:${DB} --run-all-tests --changes-for=server2 --difftype=sql

mysqldbcompare -v --run-all-tests --server1=host1 --server2=host2 proddb:proddb --skip-object-compare -a --width=100
mysqldbcompare -vv --run-all-tests --server1=localhost --server2=remotehost proddb --skip-object-compare --changes-for=server2 -a -- skip-data-check
mysqldbcompare -v --run-all-tests --server1=host1 --server2=host2 proddb:devdb --skip-data-check --changes-for=server2 -a -- disable-binary-logging --skip-checksum-table

mysqldbcompare -vvv --run-all-tests --server1=master_host --server2=slave_host proddb:proddb --changes-for=server1 --disable-binary-logging -a --format=tab
mysqldbcompare -v --run-all-tests --server1=host1 --server2=host2 proddb:devdb --skip-data-check --changes-for=server2 -- disable-binary-logging --skip-row-count --skip-diff

mysqldbcompare --server1=root@host1 --server2=root@host2 --difftype=sql db1:db2 --width=120
mysqldbcompare --server1=root:root@localhost --server2=root:root@localhost db1:db2 --changes-for=server1 -a --difftype=sql

mysql db compare options:
  --version             show program's version number and exit
  --help                  display a help message and exit
  --license              display program's license and exit
  --server1=SERVER1     connection information for first server in the form:
                                    user[:password]@host[:port][:socket] or  login-path[:port][:socket].
  --server2=SERVER2     connection information for second server in the form:
                                    user[:password]@host[:port][:socket] or login-path[:port][:socket].

  --character-set=CHARSET      sets client character set. The default is retrieved from server variable 'character_set_client'.
  -f FORMAT, --format=FORMAT   display the output in either grid (default), tab, csv, or vertical format
  --skip-checksum-table         skip CHECKSUM TABLE step in data consistency check.
  --skip-object-compare         skip object comparison step.
  --skip-row-count                 skip row count step.
  --skip-diff                           skip the object diff step.
  --skip-data-check                skip data consistency check.
  --skip-table-options             skip check of all table options (e.g., AUTO_INCREMENT, ENGINE, CHARSET, etc.).

  --width=WIDTH                  display width
  -t, --run-all-tests                 do not abort when a diff test fails
  -a, --all                               check all databases, -a option to ensure that the data consistency test is run.
  -x EXCLUDE, --exclude=EXCLUDE      exclude one or more databases from the operation using either a specific name (e.g. db1), a LIKE pattern (e.g. db%) or a REGEXP search pattern. To use a REGEXP search pattern for all exclusions, you must also specify the --regexp option. Repeat the --exclude option for multiple exclusions.
  -c, --compact                     compact output from a diff.
  --disable-binary-logging     turn binary logging off during operation if enabled (SQL_LOG_BIN=1).
           Note: may require SUPER privilege. Prevents compare operations from being written to the binary log.

  --span-key-size=SPAN_KEY_SIZE   changes the size of the key used for comparing table contents. A higher value can help to get more accurate results comparing large databases, but may slow the algorithm. Default value is 8.
  --use-indexes=USE_INDEXES   for each table, indicate which index to use as if were a primary key (each of his columns must not allow null values).
  -v, --verbose         control how much information is displayed. e.g., -v =  verbose, -vv = more verbose, -vvv = debug
  -q, --quiet             turn off all messages for quiet execution.
  -d DIFFTYPE, --difftype=DIFFTYPE   display differences in context format in one of the following formats: [unified|context|differ|sql] (default: unified).

  --changes-for=CHANGES_FOR    specify the server to show transformations to match the other server.
                     For example, to see the transformation for transforming server1 to match server2, use --changes-for=server1. Valid values are  'server1' or 'server2'. The default is 'server1'.
  --show-reverse         produce a transformation report containing the SQL statements to transform the object definitions specified in reverse. For example if --changes-for is set to server1, also generate the transformation for server2. 
                                 Note: the reverse changes are annotated and marked as comments.
  -G, --basic-regexp, --regexp    use 'REGEXP' operator to match the pattern. Default is to use 'LIKE'.

  --ssl-ca=SSL_CA           The path to a file that contains a list of trusted SSL  CAs.
  --ssl-cert=SSL_CERT     The name of the SSL certificate file to use for establishing a secure connection.
  --ssl-key=SSL_KEY       The name of the SSL key file to use for establishing a  secure connection.
  --ssl=SSL                     Specifies if the server connection requires the use of SSL. If an encrypted connection cannot be established, the connection attempt fails. By default 0 (SSL not required).


Related MySQL Articles:  
mysqlshow utility commands   mysqlbinlog utility commands


January 20, 2022

MySQL - mysqlbackup commands

mysqlbackup commands in MySQL database


mysqlbackup utility in MySQL/MariaDB to perform complete or full backups and incremental backups. And to restore full/incremental backups.

mysqlbackup --defaults-file=/usr/local/mysql/my.cnf backup
mysqlbackup --defaults-file=/usr/local/mysql/my.cnf --compress --user=backupadmin --password --port=3309 backup
mysqlbackup --show-progress --show-progress=file:meb_output --backup-dir=/full-backup backup
mysqlbackup --user=dba --password --port=3306 --with-timestamp --backup-dir=/export/backups backup

mysqlbackup --backup-dir=/export/backups/latest backup
mysqlbackup --incremental --start-lsn=1234567 --incremental-backup-dir=/path/to/incbackup backup
mysqlbackup --incremental --incremental-backup-dir=/var/mysql/backup/latest --incremental-base=dir:/var/mysql/backup/previous backup
mysqlbackup --incremental-with-redo-log-only --incremental-backup-dir=/var/mysql/backup/latest --incremental-base=dir:/var/mysql/backup/previous backup
mysqlbackup --backup-dir=/path/to/backup apply-log

mysqlbackup --src-entry=meta/comments.txt --dst-entry=/tmp/my-comments.txt --backup-image=/var/myimage.bki extract
mysqlbackup --user=mysqlbackup --password --host=127.0.0.1 --backup-image=/home/mysqlbackup/backups/my.mbi --backup-dir=/home/mysqlbackup/backup-tmp backup-to-image
mysqlbackup --user=mysqlbackup --backup-image=/backup/my.mbi list-image
mysqlbackup -uroot --backup-dir=/logs/backupext validate
mysqlbackup -uroot --backup-image=/logs/fullimage.mi validate
mysqlbackup --backup-image=/meb/backups/image.mbi --decrypt --key-file=/meb/enckeyfile validate
mysqlbackup --datadir=/home/admin/bin/mysql-8.0.26/datadir --backup-image=/home/mysqlbackup/backups/my.mbi --backup-dir=/home/mysqlbackup/backup-tmp copy-back-and-apply-log


Related MySQL Articles:  MySQL mysqldbexport cheatsheet   mysqlpump commands in MySQL


January 4, 2020

MySQL mysqldump utility commands

mysqldump commands in MySQL

mysqldump ==> used to take backup, dumping structure and contents of MySQL databases and tables

Usage: mysqldump [OPTIONS] database [tables]
OR     mysqldump [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]
OR     mysqldump [OPTIONS] --all-databases [OPTIONS]

mysqldump --help
mysqldump --version
mysqldump --print-defaults

mysqldump -u root -psecret -e "show databases;"
mysqldump -u admin --all-databases
mysqldump -u root -psecret --all-databases > all_database_dump.sql
mysqldump -u master --all-databases --single-transaction --master-data=1 > /mysql_dump/masterdump.sql

mysqldump -u search --password=secret --host=10.40.5.148 --port=3306 --add-drop-table --add-drop-database --add-locks --compress --routines --databases searchdb --result-file=master-dump-26102018.sql
mysqldump -u root -psecret --databases testdb

/usr/bin/mysqldump --user="master" --password="mysql_password" --opt --flush-privileges mydb >/backup/mysql_dump/backup_mysql_db_$(date +%Y%m%d-%H%M).dmp 
mysqldump --user="master" --password="mysql_password" --opt --force --flush-privileges mydb >/u06/mysql_dumps/backup_mysql_db_$(date +%Y%m%d-%H%M).dmp 

# mysqldump -u username -p databasename > /mysql_dump/backup.sql 
$ mysqldump --all-databases --no-data > /tmp/schema.sql
mysqldump --login-path=dba --verbose --single-transaction devdb --no-data
$ mysqldump --all-databases --lock-tables > mysql_backup.sql
~mysql/bin/mysql -u username -ppassword dbname --lock-all-tables  --opt  < /mysql/dbname.sql

mysqldump -u root -p --opt newdatabase > /mysql/newdatabase.sql
mysqldump world_db > /mysql/world_db_backup.sql
mysqldump world_db city_tbl country_tbl > /home/mysql/city_country_backup.sql
mysqldump --verbose -uroot -p mysql >/backup/mysql_backup/mysql.dmp
mysqldump --databases world_db testdb > world_testdb_backups.sql

mysqldump world_db city_tbl | mysql testdb # copying table from one MySQL db to another MySQL db
mysqldump -u root -psecret --quick --databases tempdb | mysql -u linuxusr -ppass -h linux006

/usr/bin/mysqldump --login-path=dba --all-databases --single_transaction --events --routines --triggers 2> /mysql/MySQLdump_mydb.log | gzip > /backup/mydb_backup.dmp.gz

/usr/bin/mysqldump --login-path=root --databases mydb --single_transaction --triggers --routines --events --set-gtid-purged=OFF  2> /mysql/MySQLdump_mydb.log | gzip > /backup/mydb_backup.dmp.gz
mysqldump --login-path=lp --databases mysqldb --set-gtid-purged=OFF --ssl=false --single-transaction --compress --routines --order-by-primary --triggers --events | mysql -u root -h localhost -p --ssl=false
mysqldump --login-path=dba --databases devdb --compress --set-gtid-purged=OFF --single-transaction --triggers --routines --events --order-by-primary --ssl=true --ssl-ca=/etc/ssl/ca.pem | mysql -u root -h satya-mysql-rds.xxxxxxx.us-east-2.rds.amazonaws.com -p --ssl=true --ssl-ca=/rdsdbdata/mysql/ssl_ca.pem

mysqldump --login-path=dba --single-transaction --order-by-primary --quick --databases test user_table --master-data=2 > user_table_dump.sql
/usr/bin/mysqldump --login-path=mylogin testdb user_table > job_execution.sql
mysqldump --login-path=dba --ignore-table=temp.exclude_me > mysql_dump.sql

mysqldump -h satya-mysql-rds.xxxxxxx.us-east-2.rds.amazonaws.com -P 3306 -u rdsadmin -p
mysqldump -u root -p –max_allowed_packet=512M -B dbname –tables tblnames > filename.mysql
mysqldump --opt --extended-insert --single-transaction --create-options --default-character-set=utf8 --user="username" -p --all-databases


Default options of mysql dump are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/etc/my.cnf ~/.my.cnf

mysqldump --help
The following groups are read: mysqldump client
The following options may be given as the first argument:
--print-defaults        Print the program argument list and exit.
--no-defaults            Don't read default options from any option file, except for login file.
--defaults-file=#        Only read default options from the given file #.
--defaults-extra-file=# Read this file after the global files are read.
--defaults-group-suffix=#  Also read groups with concat(group, suffix)
--login-path=#          Read this path from the login file.

  -A, --all-databases Dump all the databases. This will be same as --databases with all databases selected.
  -Y, --all-tablespaces  Dump all the tablespaces.
  -y, --no-tablespaces Do not dump any tablespace information.
  --add-drop-database Add a DROP DATABASE before each create.
  --add-drop-table    Add a DROP TABLE before each create. (Defaults to on; use --skip-add-drop-table to disable.)
  --add-drop-trigger  Add a DROP TRIGGER before each create.
  --add-locks          Add locks around INSERT statements. (Defaults to on; use --skip-add-locks to disable.)
  --allow-keywords    Allow creation of column names that are keywords.
  --apply-slave-statements     Adds 'STOP SLAVE' prior to 'CHANGE MASTER' and 'START SLAVE' to bottom of dump.
  --bind-address=name       IP address to bind to.
  --character-sets-dir=name     Directory for character set files.
  -i, --comments      Write additional information. (Defaults to on; use --skip-comments to disable.)

  --compatible=name   Change the dump to be compatible with a given mode. By default tables are dumped in a format optimized for MySQL. Legal modes are: ansi, mysql323, mysql40, postgresql, oracle, mssql, db2, maxdb, no_key_options, no_table_options, no_field_options. One can use several modes separated by commas. Note: Requires MySQL server  version 4.1.0 or higher. This option is ignored with earlier server versions.
  --compact           Give less verbose output (useful for debugging). Disables structure comments and header/footer constructs.  Enables options --skip-add-drop-table --skip-add-locks  --skip-comments --skip-disable-keys --skip-set-charset.
  -c, --complete-insert Use complete insert statements.
  -C, --compress      Use compression in server/client protocol.
  -a, --create-options  Include all MySQL specific create options.   (Defaults to on; use --skip-create-options to disable.)
  -B, --databases     Dump several databases. Note the difference in usage; in this case no tables are given. All name arguments are regarded as database names. 'USE db_name;' will be included in the output.
  -#, --debug[=#]      This is a non-debug version. Catch this and exit.
  --debug-check        Check memory and open file usage at exit.
  --debug-info        Print some debug info at exit.
  --default-character-set=name   Set the default character set.
  --delayed-insert    Insert rows with INSERT DELAYED.
  --delete-master-logs     Delete logs on master after backup. This automatically  enables --master-data.
  -K, --disable-keys  '/*!40000 ALTER TABLE tb_name DISABLE KEYS */; and
                      '/*!40000 ALTER TABLE tb_name ENABLE KEYS */; will be put in the output. (Defaults to on; use --skip-disable-keys to disable.)

  --dump-slave[=#]    This causes the binary log position and filename of the master to be appended to the dumped data output. Setting the value to 1, will printit as a CHANGE MASTER command in the dumped data output; if equal to 2, that command will be prefixed with a comment symbol. This option will turn --lock-all-tables on, unless --single-transaction is specified too (in which case a global read lock is only taken a short time at the beginning of the dump - don't forget to read about --single-transaction below). In all cases any action on logs will happen at the exact moment of the dump.Option automatically turns --lock-tables off.
  -E, --events        Dump events.
  -e, --extended-insert Use multiple-row INSERT syntax that include several VALUES lists. (Defaults to on; use --skip-extended-insert to disable.)
  --fields-terminated-by=name Fields in the output file are terminated by the given  string.
  --fields-enclosed-by=name Fields in the output file are enclosed by the given character.
  --fields-optionally-enclosed-by=name     Fields in the output file are optionally enclosed by the given character.
  --fields-escaped-by=name Fields in the output file are escaped by the given character.
  -F, --flush-logs    Flush logs file in server before starting dump. Note that if you dump many databases at once (using the option --databases= or --all-databases), the logs will be flushed for each database dumped. The exception is when using --lock-all-tables or --master-data: in this case the logs will be flushed only once, corresponding to the moment all tables are locked. So if you want your dump and the log flush to happen at the same exact moment you should use --lock-all-tables or --master-data with --flush-logs.
  --flush-privileges     Emit a FLUSH PRIVILEGES statement after dumping the mysql database. This option should be used any time the dump contains the mysql database and any other database that depends on the data in the mysql database for proper restore.
  -f, --force          Continue even if we get an SQL error.

  -?, --help           Display this help message and exit.
  --hex-blob          Dump binary strings (BINARY, VARBINARY, BLOB) in hexadecimal format.
  -h, --host=name     Connect to host.
  --ignore-table=name    Do not dump the specified table. To specify more than one table to ignore, use the directive multiple times, once for each table.  Each table must be specified with both database and table names, e.g., --ignore-table=database.table.
  --include-master-host-port     Adds 'MASTER_HOST=, MASTER_PORT=' to 'CHANGE MASTER TO..' in dump produced with --dump-slave.
  --insert-ignore     Insert rows with INSERT IGNORE.
  --lines-terminated-by=name    Lines in the output file are terminated by the given string.
  -x, --lock-all-tables Locks all tables across all databases. This is achieved by taking a global read lock for the duration of the whole dump. Automatically turns --single-transaction and  --lock-tables off.
  -l, --lock-tables   Lock all tables for read. (Defaults to on; use --skip-lock-tables to disable.)
  --log-error=name    Append warnings and errors to given file.

  --master-data[=#]   This causes the binary log position and filename to be appended to the output. If equal to 1, will print it as a CHANGE MASTER command; if equal to 2, that command will be prefixed with a comment symbol. This option will turn --lock-all-tables on, unless --single-transaction is specified too (in which case a global read lock is only taken a short time at the beginning of the dump; don't forget to read about --single-transaction below). In all cases, any action on logs will happen at the exact moment of the dump. Option automatically turns --lock-tables off.
  --max-allowed-packet=# The maximum packet length to send to or receive from server.
  --net-buffer-length=#     The buffer size for TCP/IP and socket communication.
  --no-autocommit      Wrap tables with autocommit/commit statements.
  -n, --no-create-db  Suppress the CREATE DATABASE ... IF EXISTS statement that  normally is output for each dumped database if --all-databases or --databases is given.

  -t, --no-create-info       Don't write table creation info.
  -d, --no-data        No row information.
  -N, --no-set-names     Same as --skip-set-charset.
  --opt               Same as --add-drop-table, --add-locks, --create-options, --quick, --extended-insert, --lock-tables, --set-charset, and --disable-keys. Enabled by default, disable with --skip-opt.
  --order-by-primary    Sorts each table's rows by primary key, or first unique key, if such a key exists.  Useful when dumping a MyISAM table to be loaded into an InnoDB table, but will make  the dump itself take considerably longer.
  -p, --password[=name]    Password to use when connecting to server. If password is not given it's solicited on the tty.
  -P, --port=#        Port number to use for connection.
  --protocol=name     The protocol to use for connection (tcp, socket, pipe, memory).
  -q, --quick         Don't buffer query, dump directly to stdout.  (Defaults to on; use --skip-quick to disable.)
  -Q, --quote-names   Quote table and column names with backticks (`).  (Defaults to on; use --skip-quote-names to disable.)
  --replace            Use REPLACE INTO instead of INSERT INTO.
  -r, --result-file=name Direct output to a given file. This option should be used in systems (e.g., DOS, Windows) that use carriage-return linefeed pairs (\r\n) to separate text lines. This option ensures that only a single newline is used.
  -R, --routines      Dump stored routines (functions and procedures).
  --set-charset       Add 'SET NAMES default_character_set' to the output. (Defaults to on; use --skip-set-charset to disable.)
  --set-gtid-purged[=name]      Add 'SET @@GLOBAL.GTID_PURGED' to the output. Possible values for this option are ON, OFF and AUTO. If ON is used and GTIDs are not enabled on the server, an error is generated. If OFF is used, this option does nothing. If AUTO is used and GTIDs are enabled on the server, 'SET @@GLOBAL.GTID_PURGED' is added to the output. If GTIDs are disabled, AUTO does nothing. If no value is supplied  then the default (AUTO) value will be considered.

  --single-transaction      Creates a consistent snapshot by dumping all tables in a single transaction. Works ONLY for tables stored in storage engines which support multiversioning (currently only InnoDB does); the dump is NOT guaranteed to be consistent for other storage engines. While a  --single-transaction dump is in process, to ensure a valid dump file (correct table contents and binary log position), no other connection should use the following statements: ALTER TABLE, DROP TABLE, RENAME TABLE, TRUNCATE TABLE, as consistent snapshot is not isolated from them. Option automatically turns off --lock-tables.
  --dump-date         Put a dump date to the end of the output.  (Defaults to on; use --skip-dump-date to disable.)
  --skip-opt             Disable --opt. Disables --add-drop-table, --add-locks,  --create-options, --quick, --extended-insert,  --lock-tables, --set-charset, and --disable-keys.
  -S, --socket=name     The socket file to use for connection.
  --secure-auth         Refuse client connecting to server if it uses old (pre-4.1.1) protocol.  (Defaults to on; use --skip-secure-auth to disable.)

  --ssl               Enable SSL for connection (automatically enabled with other flags).
  --ssl-ca=name        CA file in PEM format (check OpenSSL docs, implies --ssl).
  --ssl-capath=name   CA directory (check OpenSSL docs, implies --ssl).
  --ssl-cert=name      X509 cert in PEM format (implies --ssl).
  --ssl-cipher=name   SSL cipher to use (implies --ssl).
  --ssl-key=name      X509 key in PEM format (implies --ssl).
  --ssl-crl=name        Certificate revocation list (implies --ssl).
  --ssl-crlpath=name  Certificate revocation list path (implies --ssl).
  --ssl-verify-server-cert Verify server's "Common Name" in its cert against hostname used when connecting. This option is disabled by default.
  --ssl-mode=name    SSL connection mode.

  -T, --tab=name       Create tab-separated textfile for each table to given path. (Create .sql and .txt files.) NOTE: This only works  if mysqldump is run on the same machine as the mysqld server.
  --tables            Overrides option --databases (-B).
  --triggers          Dump triggers for each dumped table.  (Defaults to on; use --skip-triggers to disable.)
  --tz-utc            SET TIME_ZONE='+00:00' at top of dump to allow dumping of TIMESTAMP data when a server has data in different time zones or data is being moved between servers with different time zones.(Defaults to on; use --skip-tz-utc to disable.)
  -u, --user=name     User for login if not current user.
  -v, --verbose       Print info about the various stages.
  -V, --version       Output version information and exit.
  -w, --where=name    Dump only selected records. Quotes are mandatory.
  -X, --xml           Dump a database as well formed XML.
  --plugin-dir=name   Directory for client-side plugins.
  --default-auth=name   Default authentication client-side plugin to use.
  --enable-cleartext-plugin    Enable/disable the clear text authentication plugin.


mysqldump variables (--variable-name=value)
and boolean options {FALSE|TRUE}  Value (after reading options)
--------------------------------- ----------------------------------------
all-databases                      FALSE
all-tablespaces                    FALSE
no-tablespaces                    FALSE
add-drop-database               FALSE
add-drop-table                    TRUE
add-drop-trigger                  FALSE
add-locks                            TRUE
allow-keywords                    FALSE
apply-slave-statements        FALSE
bind-address                      (No default value)
character-sets-dir                (No default value)
comments                          TRUE
compatible                        (No default value)
compact                            FALSE
complete-insert                   FALSE
compress                           FALSE
create-options                    TRUE
databases                          FALSE
debug-check                      FALSE
debug-info                         FALSE
default-character-set          utf8
delayed-insert                    FALSE
delete-master-logs              FALSE
disable-keys                       TRUE
dump-slave                        0
events                                FALSE
extended-insert                   TRUE
fields-terminated-by              (No default value)
fields-enclosed-by                 (No default value)
fields-optionally-enclosed-by     (No default value)
fields-escaped-by                 (No default value)
flush-logs                          FALSE
flush-privileges                  FALSE
force                                FALSE
hex-blob                           FALSE
host                                 (No default value)
include-master-host-port   FALSE
insert-ignore                     FALSE
lines-terminated-by           (No default value)
lock-all-tables                   FALSE
lock-tables                       TRUE
log-error                         (No default value)
master-data                    0
max-allowed-packet         25165824
net-buffer-length             1046528
no-autocommit                FALSE
no-create-db                   FALSE
no-create-info                 FALSE
no-data                          FALSE
order-by-primary            FALSE
port                              3306
quick                             TRUE
quote-names                  TRUE
replace                           FALSE
routines                          FALSE
set-charset                     TRUE
single-transaction           FALSE
dump-date                     TRUE
socket                            /var/lib/mysql/mysql.sock
secure-auth                   TRUE
ssl                                FALSE
ssl-ca                            (No default value)
ssl-capath                      (No default value)
ssl-cert                          (No default value)
ssl-cipher                        (No default value)
ssl-key                           (No default value)
ssl-crl                            (No default value)
ssl-crlpath                      (No default value)
ssl-verify-server-cert       FALSE
tab                                (No default value)
triggers                          TRUE
tz-utc                             TRUE
user                               (No default value)
verbose                           FALSE
where                             (No default value)
plugin-dir                        (No default value)
default-auth                     (No default value)
enable-cleartext-plugin      FALSE


Related MySQL Articles:  
mysqladmin commands    mysqlcheck utility commands


August 2, 2019

mysqlrplsync utility cheatsheet

MySQL mysqlrplsync utility

mysqlrplsync - replication synchronization checker utility

mysqlrplsync utility, in MySQL, used to
  • check replication servers for synchronization of replicated events.
  • check data consistency between a master and slaves or between two slaves.
  • synchronize the replicated data on the servers.

Usage: mysqlrplsync --master=user:pass@host:port --slaves=user:pass@host:port [db_name[.tbl_name]]

mysqlrplsync -help
mysqlrplsync -version

mysql rpl sync Options:
  --version             show program's version number and exit
  --help                 display a help message and exit
  --license             display program's license and exit
  --discover-slaves-login=DISCOVER at startup, query master for all registered slaves and use the user name and password specified to connect.
                        Supply the user and password in the form user[:password] or login-path. For example, --discover-slaves-login=joe:secret will use 'joe' as the user and 'secret' as the password for each  discovered slave.
  --master=MASTER       connection information for master server in the form:
                        user[:password]@host[:port][:socket] or  login-path[:port][:socket] or config-path[[group]].
  --slaves=SLAVES       connection information for slave servers in the form:
                        user[:password]@host[:port][:socket] or login-path[:port][:socket] or config-path[[group]]. List multiple slaves in comma-separated list.
  --ssl-ca=SSL_CA       path to a file that contains a list of trusted SSL   CAs.
  --ssl-cert=SSL_CERT   name of the SSL certificate file to use for  establishing a secure connection.
  --ssl-key=SSL_KEY     name of the SSL key file to use for establishing a secure connection.
  --ssl=SSL             specifies if the server connection requires use of SSL. If an encrypted connection cannot be established,  the connection attempt fails. By default 0 (SSL not required).
  -v, --verbose         control how much information is displayed. e.g., -v = verbose, -vv = more verbose, -vvv = debug
  --rpl-timeout=RPL_TIMEOUT maximum timeout in seconds to wait for synchronization  (slave waiting to catch up to master). Default = 300.
  --checksum-timeout=CHECKSUM_TIMEOUT  maximum timeout in seconds to wait for CHECKSUM query to complete. Default = 5.
  -i INTERVAL, --interval=INTERVAL  interval in seconds for polling slaves for sync status. Default = 3.
  --exclude=EXCLUDE     databases or tables to exclude. Example:    db_name[.tbl_name]. List multiple names in a  comma-separated list.

Introduction
------------
The mysqlrplsync utility is designed to check if replication servers with GTIDs enabled are synchronized. In other words, it checks the data consistency between a master and a slave or between two slaves.

The utility permits you to run the check while replication is active. The synchronization algorithm is applied using GTID information to identify those transactions that differ (missing, not read, etc.) between the servers. During the process, the utility waits for the slave to catch up to the master to ensure all GTIDs have been read prior to performing the data consistency check.

Note: if replication is not running (e.g., all slaves are stopped), the utility can still perform the check, but the step to wait for the slave to catch up to the master will be skipped. If you want to run the utility on a stopped replication topology, you should ensure the slaves are up to date first.

By default, all data is included in the comparison. To check specific databases or tables, list each element as a separated argument for the utility using full qualified names as shown in the following examples.

  # Check the data consistency of a replication topology, explicitly specifying the master and slaves.
  $ mysqlrplsync --master=root:pass@host1:3306  --slaves=rpl:pass@host2:3306,rpl:pass@host3:3306

  # Check the data consistency of a replication topology, specifying the master and using the slaves discovery feature.
  $ mysqlrplsync --master=root:pass@host1:3306  --discover-slaves-login=rpl:pass

  # Check the data consistency only between specific slaves (no check performed on the master).
  $ mysqlrplsync --slaves=rpl:pass@host2:3306,rpl:pass@host3:3306

  # Check the data consistency of a specific database (db1) and table (db2.t1), explicitly specifying master and slaves.
  $ mysqlrplsync --master=root:pass@host1:3306 --slaves=rpl:pass@host2:3306,rpl:pass@host3:3306 db1 db2.t1

  # Check the data consistency of all data excluding a specific database (db2) and table (db1.t2), specifying the master and using slave discovery.
  $ mysqlrplsync --master=root:pass@host1:3306  --discover-slaves-login=rpl:pass --exclude=db2,db1.t2

Helpful Hints
-------------
  - The default timeout for performing the table checksum is 5 seconds.  This value can be changed with the --checksum-timeout option.
  - The default timeout for waiting for slaves to catch up is 300 seconds.  This value can be changed with the --rpl-timeout option.
  - The default interval to periodically verify if a slave has read all of the GTIDs from the master is 3 seconds. This value can be changed with the --interval option.


Related MySQL Articles: 

June 14, 2019

mysqlfrm utility in MySQL

MySQL utility - mysqlfrm cheatsheet

mysqlfrm          show CREATE TABLE from .frm files and .frm/.idb files reader utility

MySQL utility mysqlfrm is designed as a recovery tool that reads .frm files and generates CREATE statements from the table definition data in the file, useful to recreate the tables on another server.

Usage: mysqlfrm --server=[user[:pass]@host[:port][:socket]|login-path[:port][:socket]] [path\tbl1.frm|db:tbl.frm]

mysqlfrm --help
mysqlfrm --version

mysqlfrm --basedir=/usr/local/bin/mysql testdb:city.frm --port=3333 --quiet
mysqlfrm --server=root:@localhost:3310 invoices.frm --port=3333
mysqlfrm --server=dba invoices.frm --port=3333 --verbose
mysqlfrm --server=root:pass@localhost:3309 /mysql/data/temp1/t1.frm /mysql/data/temp2/g1.frm --port=3310
mysqlfrm --server=root:pass@localhost:3309 /mysql/data/temp1/t1.frm /mysql/data/temp2/db1:t2.frm --port=3310

mysqlfrm --server=mysql_dba /mysql/data/temp1/t1.frm /mysql/data/temp2/g1.frm --port=3310 --user=user
mysqlfrm --diagnostic /mysql/data/testdatabase
mysqlfrm --diagnostic /usr/local/mysql/data/new_table.frm
mysqlfrm --diagnostic /mysql/data/employee.frm > /mysql/data/recovered_emp.sql

mysqlfrm --server=root:password@localhost:3308 F:\mysql\utilities\mysqlfrm\File.frm > file.txt --diagnostic
mysqlfrm --server=root:pass@localhost --port=3310 --user=mysql /usr/local/mysql/data/employees
mysqlfrm --server=root:pass@localhost --diagnostic --show-stats --new-storage-engine=MEMORY /usr/local/mysql/data/employees/titles.frm

mysqlfrm Options:
  --version                    show program's version number and exit
  --license                     display program's license and exit
  --help
  --basedir=BASEDIR     the base directory for the server
  --diagnostic                read the frm files byte-by-byte to form the CREATE statement. May require the --server or --basedir options to decipher character set information

  --new-storage-engine=NEW_ENGINE  change ENGINE clause to use this engine.
  --frmdir=FRMDIR       save the new .frm files in this directory. Used and valid with --new-storage-engine only.
  --port=PORT              Port to use for the spawned server.
  -s, --show-stats         show file statistics and general table information.
  --server=SERVER       connection information for the server in the form: [:password]@host[:port][:socket] or
                        login-path[:port][:socket] (optional) - if provided, the storage engine and character set information will be validated against this server.

  --user=USER       user account to launch spawned server. Required if running as root user. Used only in default mode.
  --start-timeout=START_TIMEOUT  Number of seconds to wait for spawned server to start.  Default = 10.
  -v, --verbose         control how much information is displayed. e.g., -v = verbose, -vv = more verbose, -vvv = debug
  -q, --quiet             turn off all messages for quiet execution.

  --ssl-ca=SSL_CA         path to a file that contains a list of trusted SSL    CAs.
  --ssl-cert=SSL_CERT   name of the SSL certificate file to use for   establishing a secure connection.
  --ssl-key=SSL_KEY     name of the SSL key file to use for establishing a  secure connection.
  --ssl=SSL                   specifies if the server connection requires use of SSL. 
If an encrypted connection cannot be established, the connection attempt fails. By default 0 (SSL not required).


Related MySQL Articles: MySQL utility mysqlprocgrep cheatsheet

May 31, 2019

mysqlauditadmin utility in MySQL

MySQL mysqlauditadmin Utility cheatsheet

mysqlauditadmin         audit log maintenance utility       

mysqlauditadmin utility allows MySQL users/DBAs to maintain the audit logs, like viewing and modifying subset of audit log control variables, 
display the audit log file status, perform rotation of audit log file, and copy audit files to other locations.

Usage: mysqlauditadmin --server=user:pass@host:port --show-options
mysqlauditadmin --help
mysqlauditadmin --version

mysqlauditadmin --show-options --server=root@localhost:3313
mysqlauditadmin rotate --server=root@localhost:3313
mysqlauditadmin rotate --server=dba -v

mysqlauditadmin --file-stats --audit-log-name=../mysql_audit_admin/data/audit.log
mysqlauditadmin --show-options --server=root@localhost:3311 policy --value=QUERIES
mysqlauditadmin --show-options --server=mysql_dba policy --value=LOGINS --verbose
mysqlauditadmin --show-options --server=root@localhost:3312 rotate_on_size --value=32000

mysqlauditadmin --audit-log-name=/mysql_audit_admin/data/audit.log copy --copy-to=/mysql_audit_admin/audit_logs
mysqlauditadmin --audit-log-name=audit.log copy --remote-login=username:hostname --copy-to=/tmp/

mysqlauditadmin usage Options:
  --version             show program's version number and exit
  --help                 display this help message and exit
  --license             display program's license and exit

  --server=SERVER       connection information for the server in the form: user[:password]@host[:port][:socket] or login-path[:port][:socket] or config-path[[group]].
  --audit-log-name=LOG_NAME    full path and file name for the audit log file. Used for stats and copy options.
  --show-options          display the audit log system variables.

  --remote-login=RLOGIN    user name and host to be used for remote login for  copying log files. Format: user:host_or_ip Password will be prompted.
  --file-stats             display the audit log file statistics.
  --copy-to=COPY_LOCATION    the location to copy the audit log file specified. The path must be locally accessible for the current user.
  --value=VALUE         value used to set variables based on the command specified. See --help for list per command.

  --ssl-ca=SSL_CA         path to a file that contains a list of trusted SSL CAs.
  --ssl-cert=SSL_CERT   name of the SSL certificate file to use for  establishing a secure connection.
  --ssl-key=SSL_KEY     name of the SSL key file to use for establishing a secure connection.
  --ssl=SSL                 specifies if the server connection requires use of SSL. If an encrypted connection cannot be established, the connection attempt fails. By default 0 (SSL not required).
  -v, --verbose            control how much information is displayed. e.g., -v = verbose, -vv = more verbose, -vvv = debug

Available Commands:
  copy                  - copy the audit log to a locally accessible path
  policy                - set the audit log policy  Values = ALL, NONE, LOGINS, QUERIES, DEFAULT
  rotate                - perform audit log rotation
  rotate_on_size   - set the rotate log size limit for auto rotation Values = 0, 4294967295


Related MySQL Articles:  mysqlrpladmin utility commands     mysqld_multi utility examples