Below are notes on some of the important variables, I took down while tuning the config file.

1. query_cache_size:
* MySQL provides one feature that can prove very handy – a query cache. In a situation where the database has to repeatedly run the same queries on the same data set, returning the same results each time, MySQL can cache the result set, avoiding the overhead of running through the data over and over and is extremely helpful on busy servers.
2. key_buffer_size:
* The value of key_buffer_size is the size of the buffer used with indexes. The larger the buffer, the faster the SQL command will finish and a result will be returned. The rule-of-thumb is to set the key_buffer_size to at least a quarter, but no more than half, of the total amount of memory on the server. Ideally, it will be large enough to contain all the indexes (the total size of all .MYI files on the server).
* A simple way to check the actual performance of the buffer is to examine four additional variables: key_read_requests, key_reads, key_write_requests, and key_writes.
* If you divide the value of key_read by the value of key_reads_requests, the result should be less than 0.01. Also, if you divide the value of key_write by the value of key_writes_requests, the result should be less than 1.
3. table_cache:
* The default is 64. Each time MySQL accesses a table, it places it in the cache. If the system accesses many tables, it is faster to have these in the cache. MySQL, being multi-threaded, may be running many queries on the table at one time, and each of these will open a table. Examine the value of open_tables at peak times. If you find it stays at the same value as your table_cache value, and then the number of opened_tables starts rapidly increasing, you should increase the table_cache if you have enough memory.
4. sort_buffer:
* The sort_buffer is very useful for speeding up myisamchk operations (which is why it is set much higher for that purpose in the default configuration files), but it can also be useful everyday when performing large numbers of sorts.
5. read_rnd_buffer_size:
* The read_rnd_buffer_size is used after a sort, when reading rows in sorted order. If you use many queries with ORDER BY, upping this can improve performance. Remember that, unlike key_buffer_size and table_cache, this buffer is allocated for each thread. This variable was renamed from record_rnd_buffer in MySQL 4.0.3. It defaults to the same size as the read_buffer_size. A rule-of-thumb is to allocate 1KB for each 1MB of memory on the server, for example 1MB on a machine with 1GB memory.
6. thread_cache:
* If you have a busy server that’s getting a lot of quick connections, set your thread cache high enough that the Threads_created value in SHOW STATUS stops increasing. This should take some of the load off of the CPU.
7. tmp_table_size:
* “Created_tmp_disk_tables” are the number of implicit temporary tables on disk created while executing statements and “created_tmp_tables” are memory-based. Obviously it is bad if you have to go to disk instead of memory all the time.

  1. [mysqld]
  2. socket=/path/to/mysql.sock
  3. datadir=/var/lib/mysql
  4. skip-locking
  5. skip-innodb
  6. # MySQL 4.x has query caching available.
  7. # Enable it for vast improvement and it may be all you need to tweak.
  8. query_cache_type=1
  9. query_cache_limit=1M
  10. query_cache_size=32M
  11. # max_connections=500
  12. # Reduced to 200 as memory will not be enough for 500 connections.
  13. # memory=key_buffer+(sort_buffer_size+read_buffer_size)*max_connections
  14. # which is now: 64 + (1 + 1) * 200 = 464 MB
  15. # max_connections = approx. MaxClients setting in httpd.conf file
  16. # Default set to 100.
  17. #max_connections=200
  18. #interactive_timeout=180
  19. interactive_timeout=100
  20. #wait_timeout=180
  21. #wait_timeout=100
  22. # Reduced wait_timeout to prevent idle clients holding connections.
  23. #wait_timeout=30
  24. wait_timeout=15
  25. connect_timeout=10
  26. # max_connect_errors is set to 10 by default
  27. #max_connect_errors=10
  28. #table_cache=256
  29. #table_cache=1024
  30. # Checked opened tables and adjusted accordingly after running for a while.
  31. table_cache=512
  32. #tmp_table_size=32M by default
  33. #thread_cache=128
  34. # Reduced it to 32 to prevent memory hogging. Also, see notes below.
  35. thread_cache=32
  36. # key_buffer=258M
  37. # Reduced it by checking current size of *.MYI files, see notes below.
  38. key_buffer=128M
  39. # Commented out the buffer sizes and keeping the default.
  40. # sort_buffer_size=2M by default.
  41. #sort_buffer_size=1M
  42. # read_buffer_size=128K by default.
  43. #read_buffer_size=1M
  44. # 1Mb of read_rnd_buffer_size for 1GB RAM — see notes below.
  45. # read_rnd_buffer_size=256K by default.
  46. #read_rnd_buffer_size=1M
  47. # myisam_sort_buffer_size used for ALTER, OPTIMIZE, REPAIR TABLE commands.
  48. # myisam_sort_buffer_size=8M by default.
  49. #myisam_sort_buffer_size=64M
  50. # thread_concurrency = 2 * (no. of CPU)
  51. thread_concurrency=2
  52. # log slow queries is a must. Many queries that take more than 2 seconds.
  53. # If so, then your tables need enhancement.
  54. log_slow_queries=/var/log/mysqld.slow.log
  55. long_query_time=2
  56. [mysql.server]
  57. user=mysql
  58. basedir=/var/lib
  59. [safe_mysqld]
  60. err-log=/var/log/mysqld.log
  61. pid-file=/var/run/mysqld/mysqld.pid
  62. open_files_limit=8192
  63. [mysqldump]
  64. quick
  65. max_allowed_packet=16M
  66. [mysql]
  67. no-auto-rehash
  68. # Remove the next comment character if you are not familiar with SQL
  69. #safe-updates
  70. [isamchk]
  71. key_buffer=64M
  72. sort_buffer=64M
  73. read_buffer=16M
  74. write_buffer=16M
  75. [myisamchk]
  76. key_buffer=64M
  77. sort_buffer=64M
  78. read_buffer=16M
  79. write_buffer=16M
  80. [mysqlhotcopy]
  81. interactive-timeout
  82. [client]
  83. socket=/path/to/mysql.sock