Spec-Zone .ru
спецификации, руководства, описания, API

15.7.3. MySQL Proxy Command Options

To start MySQL Proxy, you can run it directly from the command line:

shell> mysql-proxy

For most situations, you specify at least the host name or address and the port number of the backend MySQL server to which the MySQL Proxy should pass queries.

You can specify options to mysql-proxy either on the command line, or by using a configuration file and the --defaults-file command-line option to specify the file location.

If you use a configuration file, format it as follows:

Failure to adhere to any of these requirements causes mysql-proxy to generate an error during startup.

The following tables list the supported configuration file and command-line options.

Table 15.4. mysql-proxy Help Options

Format Option File Description
--help Show help options
--help-admin Show admin module options
--help-all Show all help options
--help-proxy Show proxy module options

Table 15.5. mysql-proxy AdminOptions

Format Option File Description
--admin-address=host:port admin-address=host:port The admin module listening host and port
--admin-lua-script=file_name admin-lua-script=file_name Script to execute by the admin module
--admin-password=password admin-password=password Authentication password for admin module
--admin-username=user_name admin-username=user_name Authentication user name for admin module
--proxy-address=host:port proxy-address=host:port The listening proxy server host and port

Table 15.6. mysql-proxy ProxyOptions

Format Option File Description Removed
--no-proxy no-proxy Do not start the proxy module
--proxy-backend-addresses=host:port proxy-backend-addresses=host:port The MySQL server host and port
--proxy-fix-bug-25371 proxy-fix-bug-25371 Enable the fix for Bug #25371 for older libmysql versions 0.8.1
--proxy-lua-script=file_name proxy-lua-script=file_name Filename for Lua script for proxy operations
--proxy-pool-no-change-user proxy-pool-no-change-user Do not use the protocol CHANGE_USER command to reset the connection when coming from the connection pool
--proxy-read-only-backend-addresses=host:port proxy-read-only-backend-addresses=host:port The MySQL server host and port (read only)
--proxy-skip-profiling proxy-skip-profiling Disable query profiling

Table 15.7. mysql-proxy ApplicationsOptions

Format Option File Description
--basedir=dir_name basedir=dir_name The base directory prefix for paths in the configuration
--daemon daemon Start in daemon mode
--defaults-file=file_name The configuration file to use
--event-threads=count event-threads=count The number of event-handling threads
--keepalive keepalive Try to restart the proxy if a crash occurs
--log-backtrace-on-crash log-backtrace-on-crash Try to invoke the debugger and generate a backtrace on crash
--log-file=file_name log-file=file_name The file where error messages are logged
--log-level=level log-level=level The logging level
--log-use-syslog log-use-syslog Log errors to syslog
--lua-cpath=dir_name lua-cpath=dir_name Set the LUA_CPATH
--lua-path=dir_name lua-path=dir_name Set the LUA_PATH
--max-open-files=count max-open-files=count The maximum number of open files to support
--pid-file=file_name pid-file=file_name File in which to store the process ID
--plugin-dir=dir_name plugin-dir=dir_name Directory containing plugin files
--plugins=plugin,... plugins=plugin,... List of plugins to load
--user=user_name user=user_name The user to use when running mysql-proxy
--version Show version information

Except as noted in the following details, all of the options can be used within the configuration file by supplying the option and the corresponding value. For example:

[mysql-proxy]log-file = /var/log/mysql-proxy.loglog-level = message

The most common usage is as a simple proxy service (that is, without additional scripting). For basic proxy operation, you must specify at least one proxy-backend-addresses option to specify the MySQL server to connect to by default:

shell> mysql-proxy
        --proxy-backend-addresses=MySQL.example.com:3306

The default proxy port is 4040, so you can connect to your MySQL server through the proxy by specifying the host name and port details:

shell> mysql --host=localhost
        --port=4040

If your server requires authentication information, this will be passed through natively without alteration by mysql-proxy, so you must also specify the required authentication information:

shell> mysql --host=localhost --port=4040
        \   --user=user_name --password=password

You can also connect to a read-only port (which filters out UPDATE and INSERT queries) by connecting to the read-only port. By default the host name is the default, and the port is 4042, but you can alter the host/port information by using the --proxy-read-only-backend-addresses command-line option.

For more detailed information on how to use these command-line options, and mysql-proxy in general in combination with Lua scripts, see Section 15.7.5, "Using MySQL Proxy".