Showing posts with label mysqldbcopy utility cheatsheet. Show all posts
Showing posts with label mysqldbcopy utility cheatsheet. Show all posts

April 12, 2019

MySQL mysqldbcopy utility commands

mysqldbcopy commands cheatsheet

mysqldbcopy       copy databases from one server to another  

mysqldbcopy utility, in MySQL, copies a database on a source server to a database on a destination server, with or without GTIDs enabled. Source and destination servers can be same or different.

Usage: mysqldbcopy --source=user:pass@host:port:socket --destination=user:pass@host:port:socket orig_db:new_db

mysqldbcopy --help
mysqldbcopy --version

mysqldbcopy --source=root:pass@localhost --destination=root:pass@localhost world:world_copy
mysqldbcopy --source=root:pass@localhost --destination=root:pass@localhost world:world_copy -vv

mysqldbcopy --source=root:pass@localhost:3310:/test123/mysql.sock --destination=root:pass@localhost:3310:/test123/mysql.sock util_test:util_test_copy
mysqldbcopy --source=source_host --destination=target_host db1:db2 --locking=lock-all

mysqldbcopy --source=source_host --destination=target_host --all --locking=lock-all --quiet
mysqldbcopy --source=root@localhost:3310 --destination=root@localhost:3311 test123 --rpl=master --rpl-user=rpl

mysqldbcopy --source=/path/to/cred.cnf[source] --destination=/path/to/cred.cnf[destination] orig_db:new_db --drop-first
mysqldbcopy --source=/path/to/cred.cnf[source] --destination=/path/to/cred.cnf[destination] orig_db:new_db --drop-first --skip-gtid --verbose




mysql db copy Options:
  --version             show program's version number and exit
  --help                display a help message and exit
  --license             display program's license and exit

  --source=SOURCE       connection information for source server in the form:   user[:password]@host[:port][:socket] or login-path[:port][:socket].
  --destination=DESTINATION connection information for destination server in the form: user[:password]@host[:port][:socket] or login-path[:port][:socket].
  --character-set=CHARSET sets the client character set. The default is retrieved from the server variable 'character_set_client'.
  -d, --drop-first      drop the new database or object if it exists

  -x EXCLUDE, --exclude=EXCLUDE exclude one or more objects from the operation using either a specific name (e.g. db1.t1), a LIKE pattern (e.g. db1.t% or 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.
  -a, --all             include all databases
  --skip=SKIP_OBJECTS   specify objects to skip in the operation in the form of a comma-separated list (no spaces). 
   Valid values = tables, views, triggers, procedures, functions, events, grants, data, create_db
  -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.

  --new-storage-engine=NEW_ENGINE  change all tables to use this storage engine if storage engine exists on the destination.
  --default-storage-engine=DEF_ENGINE change all tables to use this storage engine if the original storage engine does not exist on the destination.
  --locking=LOCKING     choose the lock type for the operation: no-locks = do not use any table locks, lock-all = use table locks but no transaction and no consistent read, snapshot
                        (default): consistent read using a single transaction.
  -G, --basic-regexp, --regexp use 'REGEXP' operator to match pattern. Default is to use 'LIKE'.

  --rpl-user=RPL_USER   the user and password for the replication user requirement, in the form: user[:password] or  login-path. E.g. rpl:passwd
  --rpl=RPL_MODE, --replication=RPL_MODE include replication information. Choices: 'master' = include the CHANGE MASTER command using the source server as the master, 'slave' = include the CHANGE MASTER command for the source server's master (only works if the source server is a slave).
  --skip-gtid           skip creation and execution of GTID statements during copy.
  --multiprocess=MULTIPROCESS use multiprocessing, number of processes to use for concurrent execution. Special values: 0 (number of processes equal to the CPUs detected) and 1 (default - no concurrency).


Related MySQL Articles:  mysqldump commands   
mysqldiskusage utility