Install MySQL Performance Tuning Primer Script
Tuning the performance of MySQL can be a really hard job to do.
There are many thinks to consider and no two servers are identical so there is no universal solution.
Tuning Primer is a script that will help you tune your mysql installation by providing very healthy recommendations based on past mysql records.
For the script to be efficient you must run the mysql server for at least 48 hours.
Installation is extremely simple:
- Download the script
- Change the permissions for the file
chmod 755 tuning-primer.sh
- Run it
- Apply the sugesttions
wget http://day32.com/MySQL/tuning-primer.sh
./tuning-primer.sh
Enjoy!
If you enjoyed this post, make sure you subscribe to my RSS feed!
- September 11th


(5 votes, average: 4.4 out of 5)














[...] Install MySQL Performance Tuning Primer Script [...]
I was doing an optimzation search and got to know abt this particluar post.Nice.
but when i try to run the shell script, i get a permission denied message.
what is the reason? I am running it as root.
Before step 2 try running:
chmod 755 tuning-primer.sh
Let me know if it woks now.
it should be
#sh tuning-primer.sh
with CentOS 5..thanks, it worked.but anyone would like to comment on my result?(the red ones)
MAX CONNECTIONS
Current max_connections = 500
Current threads_connected = 6
Historic max_used_connections = 32
The number of used connections is 6% of the configured maximum.
You are using less than 10% of your configured max_connections.
Lowering max_connections could help to avoid an over-allocation of memory
See “MEMORY USAGE” section to make sure you are not over-allocating
MEMORY USAGE
Max Memory Ever Allocated : 327 M
Configured Max Per-thread Buffers : 2 G
Configured Max Global Buffers : 170 M
Configured Max Memory Limit : 2 G
Physical Memory : 1.97 G
Max memory limit exceeds 90% of physical memory
KEY BUFFER
Current MyISAM index space = 5 M
Current key_buffer_size = 96 M
Key cache miss rate is 1 : 1663
Key buffer fill ratio = 1.00 %
Your key_buffer_size seems to be too high.
Perhaps you can use these resources elsewhere
QUERY CACHE
Query cache is enabled
Current query_cache_size = 64 M
Current query_cache_used = 39 M
Current query_cache_limit = 4 M
Current Query cache Memory fill ratio = 61.21 %
Current query_cache_min_res_unit = 4 K
Query Cache is 16 % fragmented
Run “FLUSH QUERY CACHE” periodically to defragment the query cache memory
If you have many small queries lower ‘query_cache_min_res_unit’ to reduce fragmentation.
MySQL won’t cache query results that are larger than query_cache_limit in size
Note! This script will still suggest raising the join_buffer_size when
ANY joins not using indexes are found.
Any comments?
i’ve tried running tuning-primer.sh on http://www.photogiga.com and it works like a horse. it’s good!
This didn’t seem to work too well.
Original my.cnf
http://pastebin.com/m60e1a5f9
After running this tuner script
http://pastebin.com/m2bd637f0
It reduced allowance greatly.
Specs:
Dual xeon 3.4GHz
4GB memory
mysql 5
cpanel 11
apache 2 / php 5
Please suggest proper settings.
why do I get permission denied when I try to run the script?
Try running:
chmod 755 tuning-primer.sh
before you run the script
I’m getting this all the time (Debian Etch) and I did the chown already:
./tuning-primer.sh: line 332: bc: command not found
Example:
TEMP TABLES
tuning-primer.sh: line 332: bc: command not found
Current max_heap_table_size = M
tuning-primer.sh: line 332: bc: command not found
Current tmp_table_size = M
Of 718 temp tables, 18% were created on disk
Effective in-memory tmp_table_size is limited to max_heap_table_size.
Created disk tmp tables ratio seems fine
TABLE SCANS
tuning-primer.sh: line 332: bc: command not found
Current read_buffer_size = M
Current table scan ratio = 4 : 1
read_buffer_size seems to be fine
TABLE LOCKING
Current Lock Wait ratio = 0 : 5781
Your table locking seems to be fine
“bc” is an arbitrary precision calculator language. It’s ordinarily installed in /usr/bin. It should be easily installed with “yum”. It looks like it’s available as a separate package.
Sorry for the late reply. I just noticed your post.
Jim
It looks like ‘yum’ is not distributed with Debian. Instead, “apt-get” is: http://www.debian.org/doc/manuals/apt-howto/ch-apt-get.en.html
It’s very likely that the update’s available via apt-get.
Jim