Mysqlknife

The missing utility for MySQL DBA:

  • Checksum tables.
  • Skip error is slave.
  • Swap Databases
  • Kill process for RDS or MySQL.

Installation

Install this tool executing the following command:

$ gem install mysqlknife

Usage

Checksum table

Compare two tables with checksum:

$ mysqlknife checksum --from h=127.0.0.1,P=3306,u=root,p=admin,d=demo_from --to h=127.0.0.1,P=3306,u=root,p=admin,d=demo_to --table foo

Skip error in slave.

$ mysqlknife skip --host 127.0.0.1 --user root --password admin --behind -120

Swap Databases

Swap tables and views between two databases.

You need to rename two databases, for example, foo and bar. You only need to run the following command and save the STDOUT output to a file and then execute DML statements.

$ mysqlknife swap --host 127.0.0.1 --user root --password admin --databases from,to > swap.sql
$ mysql -h 127.0.0.1 -u root -padmin < swap.sql

Kill process

This action permit kill MySQL process in Amazon RDS or normal service, and log output who kill.

Please, follow next instructions to kill process:

$ mysqlknife kill --host 127.0.0.1 --user root --pass admin --where "time >= 200" --list
$ mysqlknife kill --host 127.0.0.1 --user root --pass admin --where "time >= 200"

Warning

  1. Do not use this tool in production before testing it.
  2. Please, use when do you need.
  3. The author is NOT responsible for misuse use of this tool.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request