Using Percona Toolkit on a remote MySQL server via SSH tunnel

The easiest way to install Percona Toolkit on MacOS is via brew:

brew install percona-toolkit

Create an SSH Tunnel to the MySQL database server, assigning it to local port 3307 (this could however be any unused port):

ssh -fNg -L 3307:127.0.0.1:3306 <user>@<dbserver>

Test the MySQL connection via the newly created SSH tunnel:

mysql -h 127.0.0.1 -P 3307 -u<user> -p

In order to remove the SSH Tunnel, find the process running with port 3307 (or which ever port you used during the tunnel creation):

ps aux | grep ssh

Now attempt to kill the process:

kill <id>

If this doesn’t work, and only as a last resort, use the -9 flag:

kill -9 <id>

Leave a Reply