Chapter 25. MySQL Proxy

Table of Contents

25.1. MySQL Proxy Supported Platforms
25.2. Installing MySQL Proxy
25.2.1. Installing MySQL Proxy from a binary distribution
25.2.2. Installing MySQL Proxy from a source distribution
25.2.3. Installing MySQL Proxy from the Subversion repository
25.3. MySQL Proxy Command Line Options
25.4. MySQL Proxy Scripting
25.4.1. Proxy Scripting Sequence During Query Injection
25.4.2. Internal Structures
25.4.3. Capturing a connection with connect_server()
25.4.4. Examining the handshake with read_handshake()
25.4.5. Examining the authentication credentials with read_auth()
25.4.6. Accessing authentication information with read_auth_result()
25.4.7. Manipulating Queries with read_query()
25.4.8. Manipulating Results with read_query_result()
25.5. Using MySQL Proxy
25.5.1. Using the Administration Interface

The MySQL Proxy is an application that communicates over the network using the MySQL Network Protocol and provides communication between one or more MySQL servers and one or more MySQL clients. In the most basic configuration, MySQL Proxy simply passes on queries from the client to the MySQL Server and returns the responses from the MySQL Server to the client.

Because MySQL Proxy uses the MySQL network protocol, any MySQL compatible client (include the command line client, any clients using the MySQL client libraries, and any connector that supports the MySQL network protocol) can connect to the proxy without modification.

In addition to the basic pass-through configuration, the MySQL Proxy is also capable of monitoring and altering the communication between the client and the server. This interception of the queries enables you to add profiling, and the interception of the exchanges is scriptable using the Lua scripting language.

By intercepting the queries from the client, the proxy can insert additional queries into the list of queries sent to the server, and remove the additional results when they are returned by the server. Using this functionality you can add informational statements to each query, for example to monitor their execution time or progress, and separately log the results, while still returning the results from the original query to the client.

The proxy allows you to perform additional monitoring, filtering or manipulation on queries without you having to make any modifications to the client and without the client even being aware that it is communicating with anything but a genuine MySQL server.

Warning

MySQL Proxy is currently an Alpha release and should not be used within production environments.

Important

MySQL Proxy is compatible with MySQL 5.0.x or later. Testing has not been performed with Version 4.1. Please provide feedback on your experiences via the MySQL Proxy Forum.

25.1. MySQL Proxy Supported Platforms

MySQL Proxy is currently available as a pre-compiled binary for the following platforms:

  • Linux (including RedHat, Fedora, Debian, SuSE) and derivatives.

  • Mac OS X

  • FreeBSD

  • IBM AIX

  • Sun Solaris

Other Unix/Linux platforms not listed should be compatible by using the source package and building MySQL Proxy locally.

System requirements for the MySQL Proxy application are the same as the main MySQL server. Currently MySQL Proxy is compatible only with MySQL 5.0.1 and later. MySQL Proxy is provided as a standalone, statically linked binary. You do not need to have MySQL or Lua installed.