MySQL Proxy

MySQL Proxy Cheatsheet #

MySQL Proxy is a tool that sits between MySQL clients and MySQL servers and allows you to monitor, filter, and alter queries sent to the server.

General Commands #

Command/OptionExampleDescription
mysql-proxy --proxy-address=<address>:<port> --proxy-user=<user> --proxy-password=<password>mysql-proxy --proxy-address=127.0.0.1:4040 --proxy-user=root --proxy-password=passwordStart MySQL Proxy with specified address and credentials
mysql-proxy --helpmysql-proxy --helpDisplay help information for MySQL Proxy

Proxy Configuration #

Command/OptionExampleDescription
--proxy-upstream-server=<server>--proxy-upstream-server=127.0.0.1:3306Specify the upstream MySQL server to connect to
--proxy-downstream--proxy-downstreamDefine the downstream server configuration (if applicable)
--proxy-read-only--proxy-read-onlySet the proxy to read-only mode

Scripting with Lua #

Command/OptionExampleDescription
--proxy-lua-script=<script_file>--proxy-lua-script=myscript.luaLoad a Lua script for advanced proxying logic
--proxy-lua-script=<script_file>--proxy-lua-script=filter.luaLoad a Lua script to filter or modify queries

Query Filtering #

Command/OptionExampleDescription
--proxy-filter--proxy-filter="SELECT * FROM my_table"Filter specific queries (basic example)
--proxy-filter=lua:<script_file>--proxy-filter=lua:filter_script.luaUse a Lua script for advanced query filtering

Status and Monitoring #

Command/OptionExampleDescription
mysql -h <proxy_address> -P <proxy_port> -u <user> -pmysql -h 127.0.0.1 -P 4040 -u root -pConnect to MySQL Proxy to monitor traffic
mysql-proxy --statusmysql-proxy --statusDisplay the current status of MySQL Proxy

Advanced Configuration #

Command/OptionExampleDescription
--proxy-server--proxy-server=server1,server2Specify multiple upstream servers for load balancing
--proxy-max-requests--proxy-max-requests=10000Limit the number of requests per session

This cheatsheet covers the essential MySQL Proxy commands and options, assisting you in configuring, scripting, and monitoring MySQL Proxy effectively.

MySQL Proxy

Explore our comprehensive cheatsheets to enhance your knowledge and efficiency. Each cheatsheet provides detailed command options, examples, and descriptions to help you master various tools and technologies.