Your Webhosting Questions
Answered by the Webhosting Experts

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






Need More Personalized Help?

If you have any further issues, questions, or would like some assistance checking on this or anything else, please reach out to us from your account and provide your server credentials within the encrypted field for the best possible security and support.

If you are unable to reach your account or if you are on the go, please reach out from your valid account email to us here at: [email protected]. We are also available to you through our phone and live chat system 24/7/365.

Tags +