You can determine the default buffer sizes used by the mysqld server using this command:
mysqld --verbose --help
This command produces a list of all mysqld options and configurable system variables. The output includes the default variable values and looks something like this:
abort-slave-event-count 0 allow-suspicious-udfs FALSE archive ON auto-increment-increment 1 auto-increment-offset 1 autocommit TRUE automatic-sp-privileges TRUE back-log 50 basedir /home/jon/bin/mysql-5.5-cluster/ ... tmpdir /tmp transaction-alloc-block-size 8192 transaction-isolation REPEATABLE-READ transaction-prealloc-size 4096 updatable-views-with-limit YES verbose TRUE wait-timeout 28800
For a mysqld server that is currently running, you can see the current values of its system variables by connecting to it and issuing this statement:
You can also see some statistical and status indicators for a running server by issuing this statement:
System variable and status information also can be obtained using mysqladmin:
MySQL uses algorithms that are very scalable, so you can usually run with very little memory. However, normally better performance results from giving MySQL more memory.
When tuning a MySQL server, the two most important variables to
should first feel confident that you have these set
appropriately before trying to change any other variables.
The following examples indicate some typical variable values for different runtime configurations.
If you have at least 1-2GB of memory and many tables and want maximum performance with a moderate number of clients, use something like this:
mysqld_safe --key_buffer_size=384M --table_open_cache=4000 \
--sort_buffer_size=4M --read_buffer_size=1M &
If you have only 256MB of memory and only a few tables, but you still do a lot of sorting, you can use something like this:
mysqld_safe --key_buffer_size=64M --sort_buffer_size=1M
If there are very many simultaneous connections, swapping problems may occur unless mysqld has been configured to use very little memory for each connection. mysqld performs better if you have enough memory for all connections.
With little memory and lots of connections, use something like this:
mysqld_safe --key_buffer_size=512K --sort_buffer_size=100K \
Or even this:
mysqld_safe --key_buffer_size=512K --sort_buffer_size=16K \
--table_open_cache=32 --read_buffer_size=8K \
If you are performing
GROUP BY or
ORDER BY operations on tables that are much
larger than your available memory, increase the value of
read_rnd_buffer_size to speed
up the reading of rows following sorting operations.
You can make use of the example option files included with your MySQL distribution; see Section 5.1.2, “Server Configuration Defaults”.
If you specify an option on the command line for mysqld or mysqld_safe, it remains in effect only for that invocation of the server. To use the option every time the server runs, put it in an option file.
To see the effects of a parameter change, do something like this:
mysqld --key_buffer_size=128M --verbose --help
The variable values are listed near the end of the output. Make
sure that the
--help options are last.
Otherwise, the effect of any options listed after them on the
command line are not reflected in the output.
For information on tuning the
engine, see Section 8.5, “Optimizing for InnoDB Tables”.