Home > MySQL and databases > MySQL tuning on cpanel servers

MySQL tuning on cpanel servers

August 20th, 2010

MySQL Web Hosting

MySQL Web Hosting

Sometimes we need to tune or optimize mySQL server configuration for better performance.

Before making any changes, I strongly recommend that you back up the file, so that you can restore it in case the service does not restart or any other problem happens:

Use the following Config for my.cnf.

1. Take backup of existing config with
cp /etc/my.cnf my.cnf.bak

2. vi /etc/my.cnf

3. Remove the whatever entry are there.

4. Add the following.

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
max_user_connections=25
max_connections=500
interactive_timeout=10
wait_timeout=10
connect_timeout=10
thread_cache_size=128
key_buffer=16M
join_buffer=1M
max_allowed_packet=16M
table_cache=1024
record_buffer=1M
sort_buffer_size=2M
read_buffer_size=2M
myisam_sort_buffer_size=64M
old-passwords = 1

[mysql.server]
user=mysqlbasedir=/var/lib

[safe_mysqld]
err-log=/var/log/mysqld.log
pid-file=/var/lib/mysql/mysql.pid
open_files_limit=8192

[mysqldump]
quickmax_allowed_packet=16M

[mysql]
no-auto-rehash

[isamchk]
key_buffer=64M
sort_buffer=64M
read_buffer=16M
write_buffer=16M
[myisamchk]
key_buffer=64M
sort_buffer=64M
read_buffer=16M
write_buffer=16M

[mysqlhotcopy]
interactive-timeout

And restart mysql on server.
# /scripts/restartsrv_mysql

MySQL and databases

  1. No comments yet.
  1. No trackbacks yet.
You must be logged in to post a comment.