<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>cPanel Admins &#187; MySQL</title>
	<atom:link href="http://www.cpaneladmins.com/category/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cpaneladmins.com</link>
	<description>Random Notes for cPanel Admins</description>
	<lastBuildDate>Wed, 08 Sep 2010 10:15:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Fix: MySQL quotas showing 0.00MB</title>
		<link>http://www.cpaneladmins.com/2010/05/06/fix-mysql-quotas-showing-0-00mb/</link>
		<comments>http://www.cpaneladmins.com/2010/05/06/fix-mysql-quotas-showing-0-00mb/#comments</comments>
		<pubDate>Thu, 06 May 2010 23:45:07 +0000</pubDate>
		<dc:creator>tech</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[db]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[mysql database]]></category>
		<category><![CDATA[mysql database size]]></category>
		<category><![CDATA[postgres]]></category>
		<category><![CDATA[postgresql]]></category>

		<guid isPermaLink="false">http://www.cpaneladmins.com/?p=300</guid>
		<description><![CDATA[If your MySQL databases are all showing 0.00MB usage, you need to enable disk_usage_include_sqldbs. 1. Fix this issue via WHM In Tweak Settings, enable &#8220;Calculate the disk usage of account MySQL and PostgreSQL databases.&#8221; The default setting is &#8220;disabled&#8221;, or unchecked. 1b. Fix this issue via SSH Or you can enable MySQL database calculation via [...]]]></description>
			<content:encoded><![CDATA[<p>If your MySQL databases are all showing 0.00MB usage, you need to enable disk_usage_include_sqldbs.</p>
<p><strong>1. Fix this issue via WHM</strong><br />
In Tweak Settings, enable &#8220;Calculate the disk usage of account MySQL and PostgreSQL databases.&#8221;</p>
<p><a href="http://www.cpaneladmins.com/wp-content/uploads/2010/05/Screen-shot-2010-07-29-at-11.13.49-PM.png"><img src="http://www.cpaneladmins.com/wp-content/uploads/2010/05/Screen-shot-2010-07-29-at-11.13.49-PM-300x45.png" alt="" title="Screen shot 2010-07-29 at 11.13.49 PM" width="300" height="45" class="alignnone size-medium wp-image-357" /></a></p>
<p>The default setting is &#8220;disabled&#8221;, or unchecked.</p>
<p><strong>1b. Fix this issue via SSH</strong><br />
Or you can enable MySQL database calculation via SSH by editing /var/cpanel/cpanel.config</p>
<p>You&#8217;ll want to search for</p>
<p><code>disk_usage_include_sqldbs=0</code></p>
<p>and change it to</p>
<p><code>disk_usage_include_sqldbs=1</code></p>
<p>If the parameter is not present, you&#8217;ll want to add it.</p>
<p><strong>2. Run the update script to perform the initial calculations:</strong><br />
Finally, to calculate your MySQL and PostgreSQL database sizes, run the following:</p>
<p><code># /scripts/update_db_cache</code></p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://www.cpaneladmins.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.cpaneladmins.com/2010/05/06/fix-mysql-quotas-showing-0-00mb/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Log MySQL Queries Not Using Indexes</title>
		<link>http://www.cpaneladmins.com/2010/03/23/log-mysql-queries-not-using-indexes/</link>
		<comments>http://www.cpaneladmins.com/2010/03/23/log-mysql-queries-not-using-indexes/#comments</comments>
		<pubDate>Wed, 24 Mar 2010 01:50:03 +0000</pubDate>
		<dc:creator>tech</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.cpaneladmins.com/?p=163</guid>
		<description><![CDATA[First, create the log file location and give mysql ownership: # touch /var/log/mysql-indexes.log #chown mysql:mysql var/log/mysql-indexes.log Edit /etc/my.cnf, and insert: log-queries-not-using-indexes = /var/log/mysql-indexes.log]]></description>
			<content:encoded><![CDATA[<p>First, create the log file location and give mysql ownership:</p>
<p><code># touch /var/log/mysql-indexes.log<br />
#chown mysql:mysql var/log/mysql-indexes.log</code></p>
<p>Edit /etc/my.cnf, and insert:</p>
<p><code>log-queries-not-using-indexes = /var/log/mysql-indexes.log</code></p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://www.cpaneladmins.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.cpaneladmins.com/2010/03/23/log-mysql-queries-not-using-indexes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Enable Logging of Slow MySQL Queries</title>
		<link>http://www.cpaneladmins.com/2009/10/10/enable-logging-of-slow-mysql-queries/</link>
		<comments>http://www.cpaneladmins.com/2009/10/10/enable-logging-of-slow-mysql-queries/#comments</comments>
		<pubDate>Sat, 10 Oct 2009 14:00:31 +0000</pubDate>
		<dc:creator>tech</dc:creator>
				<category><![CDATA[Logs]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.cpaneladmins.com/?p=78</guid>
		<description><![CDATA[MySQL has a feature that allows you to log slow running queries to a file. To enable you just need to add some lines to your my.cnf file, and restart. Insert the following into /etc/my.cnf: log-slow-queries = /var/log/mysql/mysql-slow.log long_query_time = 5 Save my.cnf and do the following when you return to a shell: #touch /var/log/mysql/mysql-slow.log [...]]]></description>
			<content:encoded><![CDATA[<p>MySQL has a feature that allows you to log slow running queries to a file. To enable you just need to add some lines to your my.cnf file, and restart. </p>
<p>Insert the following into /etc/my.cnf:</p>
<p><code>log-slow-queries = /var/log/mysql/mysql-slow.log<br />
long_query_time = 5</code></p>
<p>Save my.cnf and do the following when you return to a shell:</p>
<p><code>#touch /var/log/mysql/mysql-slow.log<br />
#chown mysql:mysql /var/log/mysql/mysql-slow.log<br />
#service mysql restart</code></p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://www.cpaneladmins.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.cpaneladmins.com/2009/10/10/enable-logging-of-slow-mysql-queries/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>MySQL Optimization Scripts</title>
		<link>http://www.cpaneladmins.com/2009/09/24/mysql-optimization-scripts/</link>
		<comments>http://www.cpaneladmins.com/2009/09/24/mysql-optimization-scripts/#comments</comments>
		<pubDate>Thu, 24 Sep 2009 14:44:11 +0000</pubDate>
		<dc:creator>tech</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.cpaneladmins.com/?p=15</guid>
		<description><![CDATA[I&#8217;ll write a complete post about how to properly optimize MySQL on a cPanel server in the future, but for now, here are links to two popular MySQL optimization scripts.  Please note that it&#8217;s recommended that your MySQL server be running for 24-48 hours before running the scripts. From Day32.com: http://www.day32.com/MySQL/tuning-primer.sh # wget http://www.day32.com/MySQL/tuning-primer.sh # [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ll write a complete post about how to properly optimize MySQL on a cPanel server in the future, but for now, here are links to two popular MySQL optimization scripts.  Please note that it&#8217;s recommended that your MySQL server be running for 24-48 hours before running the scripts.</p>
<p>From Day32.com:</p>
<p><a href="http://www.day32.com/MySQL/tuning-primer.sh" target="_top">http://www.day32.com/MySQL/tuning-primer.sh</a></p>
<p><code><br />
# wget http://www.day32.com/MySQL/tuning-primer.sh<br />
# sh tuning-primer.sh<br />
</code></p>
<p>Sample output:<br />
<code><br />
-- MYSQL PERFORMANCE TUNING PRIMER --<br />
- By: Matthew Montgomery -</code></p>
<p>MySQL Version 5.0.81-community i686</p>
<p>Uptime = 14 days 0 hrs 20 min 44 sec<br />
Avg. qps = 10<br />
Total Questions = 12160398<br />
Threads Connected = 3</p>
<p>Server has been running for over 48hrs.<br />
It should be safe to follow these recommendations</p>
<p>To find out more information on how each of these<br />
runtime variables effects performance visit:</p>
<p>http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html</p>
<p>Visit http://www.mysql.com/products/enterprise/advisors.html<br />
for info about MySQL&#8217;s Enterprise Monitoring and Advisory Service</p>
<p>SLOW QUERIES<br />
The slow query log is NOT enabled.<br />
Current long_query_time = 10 sec.<br />
You have 90 out of 12160419 that take longer than 10 sec. to complete<br />
Your long_query_time may be too high, I typically set this under 5 sec.</p>
<p>BINARY UPDATE LOG<br />
The binary update log is NOT enabled.<br />
You will not be able to do point in time recovery<br />
See http://dev.mysql.com/doc/refman/5.0/en/point-in-time-recovery.html</p>
<p>WORKER THREADS<br />
Current thread_cache_size = 8<br />
Current threads_cached = 5<br />
Current threads_per_sec = 0<br />
Historic threads_per_sec = 0<br />
Your thread_cache_size is fine</p>
<p>MAX CONNECTIONS<br />
Current max_connections = 100<br />
Current threads_connected = 3<br />
Historic max_used_connections = 101<br />
The number of used connections is 101% of the configured maximum.<br />
You should raise max_connections</p>
<p>MEMORY USAGE<br />
Max Memory Ever Allocated : 1.63 G<br />
Configured Max Per-thread Buffers : 1.20 G<br />
Configured Max Global Buffers : 426 M<br />
Configured Max Memory Limit : 1.61 G<br />
Physical Memory : 3.96 G<br />
Max memory limit seem to be within acceptable norms</p>
<p>KEY BUFFER<br />
Current MyISAM index space = 108 M<br />
Current key_buffer_size = 384 M<br />
Key cache miss rate is 1 : 3157<br />
Key buffer free ratio = 85 %<br />
Your key_buffer_size seems to be fine</p>
<p>QUERY CACHE<br />
Query cache is enabled<br />
Current query_cache_size = 32 M<br />
Current query_cache_used = 18 M<br />
Current query_cache_limit = 1 M<br />
Current Query cache Memory fill ratio = 59.10 %<br />
Current query_cache_min_res_unit = 4 K<br />
MySQL won&#8217;t cache query results that are larger than query_cache_limit in size</p>
<p>SORT OPERATIONS<br />
Current sort_buffer_size = 2 M<br />
Current read_rnd_buffer_size = 8 M<br />
Sort buffer seems to be fine</p>
<p>JOINS<br />
Current join_buffer_size = 132.00 K<br />
You have had 53627 queries where a join could not use an index properly<br />
You should enable &#8220;log-queries-not-using-indexes&#8221;<br />
Then look for non indexed joins in the slow query log.<br />
If you are unable to optimize your queries you may want to increase your<br />
join_buffer_size to accommodate larger joins in one pass.</p>
<p>Note! This script will still suggest raising the join_buffer_size when<br />
ANY joins not using indexes are found.</p>
<p>OPEN FILES LIMIT<br />
Current open_files_limit = 4096 files<br />
The open_files_limit should typically be set to at least 2x-3x<br />
that of table_cache if you have heavy MyISAM usage.<br />
Your open_files_limit value seems to be fine</p>
<p>TABLE CACHE<br />
Current table_cache value = 512 tables<br />
You have a total of 4104 tables<br />
You have 512 open tables.<br />
Current table_cache hit rate is 1%, while 100% of your table cache is in use<br />
You should probably increase your table_cache</p>
<p>TEMP TABLES<br />
Current max_heap_table_size = 16 M<br />
Current tmp_table_size = 32 M<br />
Of 1081722 temp tables, 35% were created on disk<br />
Effective in-memory tmp_table_size is limited to max_heap_table_size.<br />
Perhaps you should increase your tmp_table_size and/or max_heap_table_size<br />
to reduce the number of disk-based temporary tables<br />
Note! BLOB and TEXT columns are not allow in memory tables.<br />
If you are using these columns raising these values might not impact your<br />
ratio of on disk temp tables.</p>
<p>TABLE SCANS<br />
Current read_buffer_size = 2 M<br />
Current table scan ratio = 1537 : 1<br />
read_buffer_size seems to be fine</p>
<p>TABLE LOCKING<br />
Current Lock Wait ratio = 1 : 1545<br />
You may benefit from selective use of InnoDB.<br />
If you have long running SELECT&#8217;s against MyISAM tables and perform<br />
frequent updates consider setting &#8216;low_priority_updates=1&#8242;<br />
If you have a high concurrency of inserts</p>
<p><strong>One more:</strong></p>
<p><a href="http://www.mysqltuner.pl">http://www.mysqltuner.pl</a><br />
<code><br />
# wget http://www.mysqltuner.pl<br />
# perl mysqltuner.pl<br />
</code></p>
<p>Sample Output:</p>
<p>&gt;&gt;  MySQLTuner 1.0.0 &#8211; Major Hayden<br />
&gt;&gt;  Bug reports, feature requests, and downloads at http://mysqltuner.com/<br />
&gt;&gt;  Run with &#8216;&#8211;help&#8217; for additional options and output filtering</p>
<p>&#8212;&#8212;&#8211; General Statistics &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
[--] Skipped version check for MySQLTuner script<br />
[OK] Currently running supported MySQL version 5.0.81-community<br />
[!!] Switch to 64-bit OS &#8211; MySQL cannot currently use all of your RAM</p>
<p>&#8212;&#8212;&#8211; Storage Engine Statistics &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
[--] Status: +Archive -BDB -Federated +InnoDB -ISAM -NDBCluster<br />
[--] Data in MyISAM tables: 374M (Tables: 3987)<br />
[--] Data in InnoDB tables: 3M (Tables: 98)<br />
[--] Data in MEMORY tables: 0B (Tables: 2)<br />
[!!] Total fragmented tables: 201</p>
<p>&#8212;&#8212;&#8211; Performance Metrics &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
[--] Up for: 14d 0h 24m 52s (12M q [10.043 qps], 491K conn, TX: 3B, RX: 1B)<br />
[--] Reads / Writes: 86% / 14%<br />
[--] Total buffers: 442.0M global + 12.3M per thread (100 max threads)<br />
[OK] Maximum possible memory usage: 1.6G (41% of installed RAM)<br />
[OK] Slow queries: 0% (91/12M)<br />
[!!] Highest connection usage: 100%  (101/100)<br />
[OK] Key buffer size / total MyISAM indexes: 384.0M/111.0M<br />
[OK] Key buffer hit rate: 100.0% (3B cached / 1M reads)<br />
[OK] Query cache efficiency: 75.8% (7M cached / 9M selects)<br />
[!!] Query cache prunes per day: 33741<br />
[OK] Sorts requiring temporary tables: 0% (1 temp sorts / 1M sorts)<br />
[!!] Joins performed without indexes: 53627<br />
[!!] Temporary tables created on disk: 35% (587K on disk / 1M total)<br />
[OK] Thread cache hit rate: 99% (2K created / 491K connections)<br />
[!!] Table cache hit rate: 1% (512 open / 38K opened)<br />
[OK] Open file limit used: 24% (1K/4K)<br />
[OK] Table locks acquired immediately: 99% (3M immediate / 3M locks)<br />
[OK] InnoDB data size / buffer pool: 3.7M/8.0M</p>
<p>&#8212;&#8212;&#8211; Recommendations &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
General recommendations:<br />
Run OPTIMIZE TABLE to defragment tables for better performance<br />
Enable the slow query log to troubleshoot bad queries<br />
Reduce or eliminate persistent connections to reduce connection usage<br />
Adjust your join queries to always utilize indexes<br />
When making adjustments, make tmp_table_size/max_heap_table_size equal<br />
Reduce your SELECT DISTINCT queries without LIMIT clauses<br />
Increase table_cache gradually to avoid file descriptor limits<br />
Variables to adjust:<br />
max_connections (&gt; 100)<br />
wait_timeout (&lt; 28800)<br />
interactive_timeout (&lt; 28800)     query_cache_size (&gt; 32M)<br />
join_buffer_size (&gt; 128.0K, or always use indexes with joins)<br />
tmp_table_size (&gt; 32M)<br />
max_heap_table_size (&gt; 16M)<br />
table_cache (&gt; 512)</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://www.cpaneladmins.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.cpaneladmins.com/2009/09/24/mysql-optimization-scripts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
