# background
Today, colleagues share the theme is Mysql-proxy, so come down to understand, do not seek mastery, just know this thing
# Introduction
Mysql-proxy is MySQL's official MySQL middleware service, which provides access to several mysql-client upstream and several mysql-server to the backend.
It uses the MySQL protocol, and any upstream that uses mysql-client can be migrated to mysql-proxy without modifying any code.
The most basic usage of mysql-proxy is to request the intermediate layer of the relay as a request intercept:
、
Further, Mysql-proxy can analyze and modify the request. Intercepting queries and modifying results is done by writing LUA scripts.
Mysql-proxy allows users to specify LUA scripts to intercept requests, parse and modify requests, and also allow users to specify the results of the Lua script's return to the server
Make changes, add some result sets, or remove some result sets.
So, fundamentally, Mysql-proxy is an officially provided framework with good extensibility that can be used to accomplish:
# Use
1. The purpose of sharing a colleague's use of proxy is because the test environment encountered the test/development classmate careless full table update/delete operation, resulting in abnormal test data, thus affecting the progress of the project, so he access to Mysql-proxy SQL statement interception Check, SQL statements can be sent to a DBA-provided SQL review service to determine if there is a problem with the SQL statement
2. Before there is such an experience, before the order through the demolition operation, the order table is divided into 128 libraries, is based on the order number to remove the library, but not all the table has the order number (historical structure of the pot), if there is a demand is based on the mobile phone number to query the order number, resulting in to traverse query 128 to determine Then we need proxy intervention, which was used by Ali's Mycat middleware
# Insufficient
Due to the addition of a layer of proxy will result in increased consumption of network requests, so performance has a certain impact;
Mysql-proxy Introduction