Skip to content

A simple tool to run MySQL queries on multiple databases and return the results.

License

Notifications You must be signed in to change notification settings

uberswe/multiquery

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

A simple tool to run MySQL queries on multiple databases and return the results.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published