Tune MySQL

Mysql set up (“my.cnf”). The MySQL config file, my.cnf.

Here is what to add under the [mysqld] heading.

The two lines, “max_connections” and “max_user_connections” are where the magic happens.
Since your Apache/PHP box is connecting to MySQL, it appears as a single user.

MySQL defaults to 1 max connection, with 1 max connection per user. The following lines make it so your Apache/PHP box can connect to your MySQL box up to the number you have set “MaxClients” to in the Apache config above. By using persistent connections, you can pretty much get Apache up,  have it connect to MySQL upon start up, and just use the persistent connections to pass data between  the two boxes rather than opening connections. Its much more efficient that way.

set-variable = max_connections = 300
(this must be higher than “MaxClients” set in Apache, or you won’t fully maximize use)
set-variable = max_user_connections = 300
set-variable = table_cache=1200
(max number of tables in join multiplied by max_user_connections)

A few other MySQL tunings:

set-variable = max_allowed_packet=1M (sanity check to stop runaway queries)
set-variable = max_connect_errors=999999
(stop mysqld from shutting down if there are connect errors – this defaults to 1 error and mysqld stops!)

This is the only needed info

There are 5 tags in my.cnf

max_connections

max_user_connections

table_cache

max_allowed_packet

ax_connect_errors

  • 115 gebruikers vonden dit artikel nuttig
Was dit antwoord nuttig?

Gerelateerde artikelen

Manage Database Roles

Solution Database roles are conceptually completely separate from operating system users....

Manage Tablespaces

Tablespaces in PostgreSQL allow database administrators to define locations in the file system...

ColdFusion DSN parameters are not updated

SYMPTOMS New CF DSN records are created.  Even the set of parameters is tried to be updated...

Finding what packages are installed on a Linux system

For distributions that use RPM format packages, use the command: $ rpm -qa You may want to pipe...

What platforms does Linux support?

Linux runs on almost every general-purpose computer made in the last 10 years. It runs on systems...