16.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 16.4 mysql-proxy Help Options

FormatOption FileDescription
--help Show help options
--help-admin Show admin module options
--help-all Show all help options
--help-proxy Show proxy module options

Table 16.5 mysql-proxy Admin Options

FormatOption FileDescription
--admin-address=host:portadmin-address=host:portThe admin module listening host and port
--admin-lua-script=file_nameadmin-lua-script=file_nameScript to execute by the admin module
--admin-password=passwordadmin-password=passwordAuthentication password for admin module
--admin-username=user_nameadmin-username=user_nameAuthentication user name for admin module
--proxy-address=host:portproxy-address=host:portThe listening proxy server host and port

Table 16.6 mysql-proxy Proxy Options

FormatOption FileDescriptionRemoved
--no-proxyno-proxyDo not start the proxy module 
--proxy-backend-addresses=host:portproxy-backend-addresses=host:portThe MySQL server host and port 
--proxy-fix-bug-25371proxy-fix-bug-25371Enable the fix for Bug #25371 for older libmysql versions0.8.1
--proxy-lua-script=file_nameproxy-lua-script=file_nameFilename for Lua script for proxy operations 
--proxy-pool-no-change-userproxy-pool-no-change-userDo not use the protocol CHANGE_USER command to reset the connection when coming from the connection pool 
--proxy-read-only-backend-addresses=host:portproxy-read-only-backend-addresses=host:portThe MySQL server host and port (read only) 
--proxy-skip-profilingproxy-skip-profilingDisable query profiling 

Table 16.7 mysql-proxy Applications Options

FormatOption FileDescription
--basedir=dir_namebasedir=dir_nameThe base directory prefix for paths in the configuration
--daemondaemonStart in daemon mode
--defaults-file=file_name Read only the given option file
--event-threads=countevent-threads=countThe number of event-handling threads
--keepalivekeepaliveTry to restart the proxy if a crash occurs
--log-backtrace-on-crashlog-backtrace-on-crashTry to invoke the debugger and generate a backtrace on crash
--log-file=file_namelog-file=file_nameThe file where error messages are logged
--log-level=levellog-level=levelThe logging level
--log-use-sysloglog-use-syslogLog errors to syslog
--lua-cpath=dir_namelua-cpath=dir_nameSet the LUA_CPATH
--lua-path=dir_namelua-path=dir_nameSet the LUA_PATH
--max-open-files=countmax-open-files=countThe maximum number of open files to support
--pid-file=file_namepid-file=file_nameFile in which to store the process ID
--plugin-dir=dir_nameplugin-dir=dir_nameDirectory containing plugin files
--plugins=plugin,...plugins=plugin,...List of plugins to load
--user=user_nameuser=user_nameThe 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.log
log-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 16.7.5, “Using MySQL Proxy”.