To start mysql-proxy you can just run the command directly. However, for most situations you will want to specify at the very least the address/host name and port number of the backend MySQL server to which the MySQL Proxy should pass on queries.
You can get a list of the supported command-line options using the
--help-all
command-line option. The majority of
these options set up the environment, either in terms of the
address/port number that mysql-proxy should
listen on for connections, or the onward connection to a MySQL
server. A full description of the options is shown below:
--help-all
— show all help options.
--help-admin
— show options for the
admin-module.
--help-proxy
— Show options for the
proxy-module.
--admin-address=host:port
— specify
the host name (or IP address) and port for the administration
port. The default is localhost:4041
.
--proxy-address=host:port
— the
listening host name (or IP address) and port of the proxy
server. The default is localhost:4040
.
--proxy-read-only-backend-address=host:port
— the listening host name (or IP address) and port of
the proxy server for read-only connections. The default is for
this information not to be set.
--proxy-backend-addresses=host:port
—
the host name (or IP address) and port of the MySQL server to
connect to. You can specify multiple backend servers by
supplying multiple options. Clients are connected to each
backend server in round-robin fashion. For example, if you
specify two servers A and B, the first client connection will
go to server A; the second client connection to server B and
the third client connection to server A.
--proxy-skip-profiling
— disables
profiling of queries (tracking time statistics). The default
is for tracking to be enabled.
--proxy-fix-bug-25371
— gets round
an issue when connecting to a MySQL server later than 5.1.12
when using a MySQL client library of any earlier version.
--proxy-lua-script=file
— specify
the Lua script file to be loaded. Note that the script file is
not physically loaded and parsed until a connection is made.
Also note that the specified Lua script is reloaded for each
connection; if the content of the Lua script changes while
mysql-proxy is running then the updated
content will automatically be used when a new connection is
made.
--daemon
— starts the proxy in daemon
mode.
--pid-file=file
— sets the name of
the file to be used to store the process ID.
--version
— show the version number.
The most common usage is as a simple proxy service (that is,
without addition 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 then this will be passed through natively without alteration by mysql-proxy, so you must also specify the authentication information if required:
shell> mysql --host=localhost --port=4040 \ --user=username --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-address
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 14.6.5, “Using MySQL Proxy”.
User Comments
Add your own comment.