Skip to content

Latest commit

 

History

History
30 lines (19 loc) · 1.28 KB

README.md

File metadata and controls

30 lines (19 loc) · 1.28 KB

MultiQuery (mq)

A simple cli tool written in Go to query multiple MySQL databases.

Sometimes I have the need to query multiple MySQL databases with the same structure. So I built this simple tool to allow me to do just that. You can connect to a mysql host directly or via an SSH tunnel.

The following query will find all the databases with the prefix wp_ and run a select query on each database and aggregate the results.

mq --host=localhost --dbprefix=wp_ --query="SELECT * FROM wp_users"

This query will ssh to another host and then connect via mysql and run the queries on individual threads

mq --host=10.10.10.100 --query="SELECT * FROM wp_users" --sshhost=wpserver --user=wp --password=[omitted] --threaded --dbprefix=wp_

Use the help command to read about the other parameters that are supported

mq --help

This tool should have no bugs but use it at your own risk. If you are concerned please review my code and feel free to fork the repository to make your own changes. Feel free to open a pull request if you would like to contribute improvements to the code.

You can also use the --threaded option to run concurrent queries.

SSH tunneling is supported if you specify an SSH host.

This tool tries to read ssh config files and my.cnf files when possible.