Optimizing Mysql For Dummies
Written by Joe on February 21, 2008 – 4:36 pm -
Sorry, this isn’t one of those new, overpriced yellow books at your local bookstore. It’s not even a book, rather a blog post about a handy tool I came across. It’s a script that’ll help you configure your mysql settings, ideal for those that aren’t fluent in database server optimization. The author doesn’t include instructions, so I’ll help make it easy for those that aren’t familiar with executing shell scripts or using ssh.
First, if you don’t already have an ssh client (much more secure than using telnet), I recommend putty. It’s a free Windows utility. You can download putty.exe from here. Nothing to install, just run it as-is. Besides using it for this tutorial, you can also run useful commands like “service mysql restart”, “service httpd restart”, and “top” to name a few. At any rate, let’s get into the mysql optimization.
You can see / edit your mysql configuration file using pico, so open putty -> type in your web address -> enter your login name (probably “root”) -> enter password and you’re in. Before we go any farther, and assuming your mysql config file is located at etc/my.cnf, let’s make a backup. Type “cp /etc/my.cnf /etc/my.cnf.bak” (without the quotes) which simply makes a copy of that file in case something goes wrong (which can and will when you play with these kinds of files). To get to your mysql config file, type ”pico /etc/my.cnf”. Here you’ll get a visual view of what’s in the file… yours likely will be a bit different.

Now, from here I’m not even going to begin to suggest what the best settings for your server / VPS might be… not only because I’m not an expert but also because every setup is different. Different memory and processor performance, your programs might be taxing your server differently, etc. But, this is why I wrote this – a great program I found written by Matthew Montgomery, called the MySQL Performance Tuning Primer Script and found here. Don’t bother downloading it to your computer, we’ll do it through ssh. Ps – before using the script make sure you mysql service had been running for at least 48 hours.
First, install it. While logged into your server through ssh, type “wget http://day32.com/MySQL/tuning-primer.sh” to download it, then “chmod u+x tuning-primer.sh” to set the proper permissions, and finally “./tuning-primer.sh” to run the program. The script will analyze your server and suggest the proper settings for settings such as Slow Query Log, Max Connections, Worker Threads, Key Buffer, Query Cache, Sort Buffer, Joins, Temp Tables, Table (Open & Definition) Cache, Table Locking, Table Scans (read_buffer), and Innodb Status.

Once you get your suggestions, exit out of the script back to the command prompt (ctrl X), then pico back into mysql’s config file “pico /etc/my.cnf” and change the settings accordingly. When finished, ctrl X back out and type “y” to save and overwrite the file (remember your backup!) You’ll need to restart mysql for the changes to take effect, so type “service mysql restart”, then I’d run a “top” command to watch the server loads… hopefully after things settle the load will be much better. Pay especial attention to the user “mysql” and how much CPU and memory it’s taking up.
I’d give it a couple days and run this optimizer again, remembering all you have to do now that it’s installed is type “./tuning-primer.sh” to run it. To close putty simple type “exit”. This is much easier then how I normally do it (playing with settings for days, watching changes work and not work – over and over), and likely better probably too. Happy optimizing!
Posted in Server Stuff | 12 Comments »

April 13th, 2009 at 8:26 am
Thanks for sharing this great tool. Is there a means to slow down the speed at which this script runs. Using putty, the first few lines just scroll up and all I can see are the last 6 or so suggestions.
May 4th, 2009 at 1:20 pm
Thanks!!!!!
November 23rd, 2009 at 3:00 pm
Nothing changes your opinion of a friend so surely as success – yours or his.
December 19th, 2009 at 5:25 am
Hi.
How are You?
Free java casino no download
casino
List flash no download casino
casino
Virtual casino birthday welcome bonus
casino
Flash no download casino without deposit
casino
Internet poker web sites
March 31st, 2010 at 9:00 pm
I was thinking I’d place a info here to train you the most effective way to create cash working with dating affiliate along with cost-free strategies. I succeeded to make four thousand bucks monthly using the steps inside this absolutely free article, http://bit.ly/5kmonthguide – click to read.
April 25th, 2010 at 10:05 am
Thanks for this but im confused on how to do via ssh.
May 1st, 2010 at 1:51 pm
gooday there, i just found your web portal via bing, and i would like to comment that you compose interestingly good via your web portal. i am truly moved by the mode that you write, and the message is superb. anyway, i would also like to know whether you would like to exchange links with my website? i will be more than happy to reciprocate and drop your link off in the blogroll. looking for your response, i give my sincere thanks and gooday!
May 10th, 2010 at 10:22 am
You should definitely check out the free $50 no deposit bonus being offered at our new Bet Phoenix Casino. Only available now at: Bet Phoenix. Good luck!
May 13th, 2010 at 6:45 pm
Great job. I’ll check and see if I can nominate your sitr to the 2010 website awards. I think this is kind of websites they are looking for.
May 31st, 2010 at 8:30 pm
Hello,this is Timmy Dopler,just observed your Post on google and i must say this blog is great.may I quote some of the Post found in this weblog to my local people?i’m not sure and what you think?in any case,Thank you!
June 15th, 2010 at 4:21 am
First thanks for the script,and second i got a lot of errors like this:
“tuning-primer.sh: line 440: bc: command not found”
how to solve it? i’m on vps..
thanks!
August 17th, 2010 at 10:46 am
Almost everyone that earnsmoney on the internet (even the millionaires) do so through affiliate marketing. Being successful in affiliate marketing involves applying the formula that makes other affiliate marketers successful. For example, autoblogging. Autoblogging has been one of the least well-known forms of making money for quite some time… basically because it’s quite difficult to make a good auto-blog. Yet, when done right, it can provide you with a perpetual passive income with the only real work required being the setting up process. Video Marketing, and several other marketing strategies are all designed to drive traffic to your site, can be incorporated steadily in order to raise the position your site appears in the SERPs when someone searches for a term related to your site. And yet, even this can be totally automated.