<?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>Linux, Open Source and Web 2.0 &#187; MySQL</title>
	<atom:link href="http://www.itecsoftware.com/category/mysql/feed" rel="self" type="application/rss+xml" />
	<link>http://www.itecsoftware.com</link>
	<description>Itec Software</description>
	<lastBuildDate>Sun, 13 May 2012 19:34:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>View Progress Of MySQL Dump Restore Or Import</title>
		<link>http://www.itecsoftware.com/view-progress-of-mysql-dump-restore-or-import?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=view-progress-of-mysql-dump-restore-or-import</link>
		<comments>http://www.itecsoftware.com/view-progress-of-mysql-dump-restore-or-import#comments</comments>
		<pubDate>Sat, 07 May 2011 19:18:50 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[bar]]></category>
		<category><![CDATA[dump]]></category>
		<category><![CDATA[import]]></category>
		<category><![CDATA[progress]]></category>
		<category><![CDATA[pv]]></category>
		<category><![CDATA[restore]]></category>

		<guid isPermaLink="false">http://www.itecsoftware.com/?p=795</guid>
		<description><![CDATA[<a href="http://www.itecsoftware.com/view-progress-of-mysql-dump-restore-or-import" title="View Progress Of MySQL Dump Restore Or Import"></a>Ever wondered why the MySQL command line tool don&#8217;t have any sort of progress information or status update? Well, you&#8217;re not alone if you do. Especially importing a GB sized dump file can take a long time, especially if the &#8230;<p class="read-more"><a href="http://www.itecsoftware.com/view-progress-of-mysql-dump-restore-or-import">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://www.itecsoftware.com/view-progress-of-mysql-dump-restore-or-import" title="View Progress Of MySQL Dump Restore Or Import"></a><!-- google_ad_section_start --><p>Ever wondered why the MySQL command line tool don&#8217;t have any sort of progress information or status update? Well, you&#8217;re not alone if you do. Especially importing a GB sized dump file can take a long time, especially if the table engine was InnoDB.</p>
<p>There are some clever utilities which can be used to accomplish just that, by giving the user simple, yet useful information about the progress of their process. Let&#8217;s look at them.</p>
<h4>Bar (Command Line Progress Bar)</h4>
<p>The Bar utility, or in full terms Command Line Progress Bar can be downloaded from <a title="Command Line Progress Bar" href="http://sourceforge.net/projects/clpbar/" target="_blank">Sourceforge</a>. If you are running Ubuntu, it&#8217;s as simple as running ‘<span style="color: #008000;">sudo apt-get install bar</span>’ to install it. You then simply pipe your MySQL import and get a nice status bar.</p>
<pre><span style="color: #008000;">shell&gt; bar -if=mysql_db_data.sql | mysql</span></pre>
<pre><span style="color: #008000;"><a href="http://www.itecsoftware.com/wp-content/uploads/2011/05/bar-1.06-screenshot1.jpg"><img class="size-full wp-image-797 alignnone" style="margin-top: 20px; margin-bottom: 20px;" title="bar-1.06-screenshot" src="http://www.itecsoftware.com/wp-content/uploads/2011/05/bar-1.06-screenshot1.jpg" alt="Bar utility screenshot" width="564" height="40" /></a>
</span></pre>
<h3></h3>
<h4><span id="more-795"></span>Piper Viewer</h4>
<p>To get a bit fancier, Piper Viewer can be inserted into any normal pipeline between two processes to give a visual indication of how quickly data is passing through, how long it has taken, how near to completion it is, and an estimate of how long it will be until completion. Observe multiple instances working in tandem,  a visual indicator of relative throughput in a complex pipeline. Download pv <a href="http://www.ivarch.com/programs/pv.shtml" target="_blank">here</a>.</p>
<pre><span style="color: #008000;">pv -cN gzip mysql_db_data.sql.gz | gzip -d | pv -cN mysql | mysql</span></pre>
<pre><span style="color: #008000;"><a href="http://www.itecsoftware.com/wp-content/uploads/2011/05/pv.png"><img class="size-full wp-image-798 alignnone" style="margin-top: 20px; margin-bottom: 20px;" title="pv Piper Viewer" src="http://www.itecsoftware.com/wp-content/uploads/2011/05/pv.png" alt="Piper Viewer" width="590" height="82" /></a></span></pre>
<pre>
</pre>
<p>Either utility will undoubtedly shed more light into your restoration processes, and let you know whether the process is still running if in doubt and wondering after an hour or more.</p>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://www.itecsoftware.com/view-progress-of-mysql-dump-restore-or-import/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cross deleting records from multiple tables in mysql</title>
		<link>http://www.itecsoftware.com/cross-deleting-records-from-multiple-tables-in-mysql?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=cross-deleting-records-from-multiple-tables-in-mysql</link>
		<comments>http://www.itecsoftware.com/cross-deleting-records-from-multiple-tables-in-mysql#comments</comments>
		<pubDate>Tue, 21 Dec 2010 23:07:37 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[multiple delete]]></category>

		<guid isPermaLink="false">http://articles.itecsoftware.com/?p=621</guid>
		<description><![CDATA[<a href="http://www.itecsoftware.com/cross-deleting-records-from-multiple-tables-in-mysql" title="Cross deleting records from multiple tables in mysql"></a>I&#8217;ve been asked many times how to delete records in multiple tables in MySQL. Here are couple of methods that should get anyone started. Simple Inner Join Method The simple inner join method uses commas with an implicit inner join &#8230;<p class="read-more"><a href="http://www.itecsoftware.com/cross-deleting-records-from-multiple-tables-in-mysql">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://www.itecsoftware.com/cross-deleting-records-from-multiple-tables-in-mysql" title="Cross deleting records from multiple tables in mysql"></a><!-- google_ad_section_start --><p>I&#8217;ve been asked many times how to delete records in multiple tables in MySQL. Here are couple of methods that should get anyone started.</p>
<h4>Simple Inner Join Method</h4>
<p>The simple inner join method uses commas with an implicit inner join like in the example below. Here we&#8217;re using an items and price table, where each table has an itemId field which is what we join them on.</p>
<pre><span style="color: #008000;">DELETE i.*, p.*
FROM items i, price p
WHERE i.itemId = p.itemId
AND i.itemId = 101</span></pre>
<h4>Traditional Inner Join Method</h4>
<p>In the traditional inner join we&#8217;re keeping the join statement clear of the where clause, but it works as well. Whatever personal preference you may have. Note that you can delete individual table records from one table only, if you require to do so.</p>
<pre><span style="color: #008000;">DELETE i.*, p.*
FROM items i
INNER JOIN price p
ON i.itemId = p.itemId
WHERE i.itemId = 101</span></pre>
<h4><span id="more-621"></span>Delete records that are missing on the second table</h4>
<p>Using a left join, we can also delete records that have no corresponding record in the joined table. The following query accomplishes that. In the example below, we delete all records in the items table that have no record in the price table.</p>
<pre><span style="color: #008000;">DELETE i.*
FROM items i
LEFT JOIN price p
ON i.itemId = p.itemId
WHERE p.itemId IS NULL</span></pre>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://www.itecsoftware.com/cross-deleting-records-from-multiple-tables-in-mysql/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WITH (NOLOCK) table hint equivalent for MySQL</title>
		<link>http://www.itecsoftware.com/with-nolock-table-hint-equivalent-for-mysql?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=with-nolock-table-hint-equivalent-for-mysql</link>
		<comments>http://www.itecsoftware.com/with-nolock-table-hint-equivalent-for-mysql#comments</comments>
		<pubDate>Mon, 06 Sep 2010 18:29:30 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[NOLOCK]]></category>
		<category><![CDATA[transaction]]></category>

		<guid isPermaLink="false">http://articles.itecsoftware.com/?p=538</guid>
		<description><![CDATA[<a href="http://www.itecsoftware.com/with-nolock-table-hint-equivalent-for-mysql" title="WITH (NOLOCK) table hint equivalent for MySQL"></a>I don&#8217;t remember how many times I was asked about an equivalent term of the infamous &#8220;NOLOCK&#8221; hint for mysql database server, hence I thought it was worth to write about it here. &#8220;WITH (NOLOCK)&#8221; is a transaction isolation levels &#8230;<p class="read-more"><a href="http://www.itecsoftware.com/with-nolock-table-hint-equivalent-for-mysql">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://www.itecsoftware.com/with-nolock-table-hint-equivalent-for-mysql" title="WITH (NOLOCK) table hint equivalent for MySQL"></a><!-- google_ad_section_start --><p>I don&#8217;t remember how many times I was asked about an equivalent term of the infamous &#8220;NOLOCK&#8221; hint for mysql database server, hence I thought it was worth to write about it here. &#8220;WITH (NOLOCK)&#8221; is a transaction isolation levels that defines how data is available during an update, or with other words it is a property that defines at what point changes made by an update operation will become available in a row, table or database to other processes.</p>
<p>The official SQL standard defines four isolation levels:</p>
<p>READ COMMITTED<br />
READ UNCOMMITTED<br />
REPEATABLE READ<br />
SERIALIZABLE</p>
<p>Oracle, SQL Server and MySQL support isolation levels. During an operation, the database engine places certain locks to maintain data integrity. Different types of locking apply to different databases (Oracle vs. MySQL), or table types (eg. MyISAM vs. InnoDB).</p>
<p>When WITH (NOLOCK) is used with SQL Server, the statement does not place a lock nor honor exclusive locks on table.  The MySQL equivalent is READ UNCOMMITTED, also known as &#8220;dirty read&#8221; because it is the lowest level of isolation. If we specify a table hint then it will override the current default isolation level. MySQL default isolation level is REPEATABLE READ which means locks will be placed for each operation, but multiple connections can read data concurrently.<span id="more-538"></span></p>
<p>SQL Server WITH (NOLOCK) looks like this:</p>
<p><span style="color: #008000;">SELECT * FROM TABLE WITH (nolock)</span></p>
<p>To achieve the same with MySQL, we change the session isolation mode using the <span style="color: #008000;">SET SESSION</span> command.</p>
<p><span style="color: #008000;">SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED ;<br />
SELECT * FROM TABLE_NAME ;<br />
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ ;</span></p>
<p>This statement will work similar to WITH (NOLOCK) i.e READ UNCOMMITTED data. We can also set the isolation level for all connections globally:</p>
<p><span style="color: #008000;">SET GLOBAL TRANSACTION ISOLATION LEVEL READ UNCOMMITTED ;</span></p>
<p>In addition, two system variables related to isolation also level exist in MySQL server:</p>
<p><span style="color: #008000;">SELECT @@global.tx_isolation;</span> (global isolation level)<br />
<span style="color: #008000;">SELECT @@tx_isolation;</span> (session isolation level)</p>
<p>Or set the isolation level inside a transaction:</p>
<p><span style="color: #008000;">SET TRANSACTION ISOLATION LEVEL REPEATABLE READ<br />
GO</span></p>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://www.itecsoftware.com/with-nolock-table-hint-equivalent-for-mysql/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Install And Use CouchDB With JSON And Map-Reduce</title>
		<link>http://www.itecsoftware.com/install-and-use-couchdb-with-json-and-map-reduce?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=install-and-use-couchdb-with-json-and-map-reduce</link>
		<comments>http://www.itecsoftware.com/install-and-use-couchdb-with-json-and-map-reduce#comments</comments>
		<pubDate>Sat, 14 Aug 2010 19:34:38 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[cassandra]]></category>
		<category><![CDATA[CouchDB]]></category>
		<category><![CDATA[erlang]]></category>
		<category><![CDATA[ICU]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[map-reduce]]></category>
		<category><![CDATA[spidermonkey]]></category>

		<guid isPermaLink="false">http://articles.itecsoftware.com/?p=511</guid>
		<description><![CDATA[<a href="http://www.itecsoftware.com/install-and-use-couchdb-with-json-and-map-reduce" title="Install And Use CouchDB With JSON And Map-Reduce"></a>CouchDB is another offspring from the open-source, NoSQL, non-relational databases and is maintained under the Apache Foundation. It differs itself form the likes of MongoDB or Cassandra in that CouchDB is storing data in so called &#8220;documents&#8221; that are in &#8230;<p class="read-more"><a href="http://www.itecsoftware.com/install-and-use-couchdb-with-json-and-map-reduce">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://www.itecsoftware.com/install-and-use-couchdb-with-json-and-map-reduce" title="Install And Use CouchDB With JSON And Map-Reduce"></a><!-- google_ad_section_start --><p>CouchDB is another offspring from the open-source, NoSQL, non-relational databases and is maintained under the Apache Foundation. It differs itself form the likes of MongoDB or Cassandra in that CouchDB is storing data in so called &#8220;documents&#8221; that are in JSON format, which can be hashes, lists, nested arrays and of course scalar values. This added complexity results in more powerful features, mainly to have a db that is not just a single key/value pair, but it comes at a price of speed reduction.</p>
<p>CouchDB can be a little bit of a pain to install, because it needs a few pre-requisites and they in turn have a few of their own quirks. This outline should help you get CouchDB with all it&#8217;s necessities installed. We&#8217;ve used MacOS, but you can substitute your OS where applicable.</p>
<p>The CouchDB source code and installer packages are downloadable <a title="Download CouchDB" href="http://www.apache.org/dyn/closer.cgi?path=/couchdb/0.11.2/apache-couchdb-0.11.2.tar.gz" target="_blank">here</a>. As of this writing, version <a href="http://www.apache.org/dyn/closer.cgi?path=/couchdb/0.11.2/apache-couchdb-0.11.2.tar.gz" target="_blank">0.11.2</a> is the latest stable version, with 1.0.1 just around the corner. You will also need <a href="http://ftp.mozilla.org/pub/mozilla.org/js/" target="_blank">Spider Monkey</a>, Mozilla&#8217;s C implementation of JavaScript.</p>
<h4>Installing SpiderMonkey</h4>
<p>Once downloaded, extract the tarball and move into the sources folder:</p>
<p><span style="color: #008000;">tar -xzvf js-1.8.0-rc1.tar.gz</span></p>
<p><span style="color: #008000;">cd js/src</span></p>
<p><span id="more-511"></span>If you&#8217;re installing SpiderMonkey on a Mac, there is a small hack to the jsprf.c file. Adding the following two lines (in orange below) after line 60 should resolve the build issue:</p>
<p>60: #define VARARGS_ASSIGN(foo, bar)        VA_COPY(foo,bar)<br />
<span style="color: #ff6600;">61: #elif defined(va_copy)<br />
62: #define VARARGS_ASSIGN(foo, bar)</span><br />
63: #elif defined(HAVE_VA_LIST_AS_ARRAY)</p>
<p>Now we should have no issue running make:</p>
<p><span style="color: #008000;"> make BUILD_OPT=1 -f Makefile.ref</span></p>
<p><span style="color: #008000;">sudo sh</span></p>
<p><span style="color: #008000;"> sudo make BUILD_OPT=1 JS_DIST=/usr/local -f Makefile.ref export</span></p>
<h4>Installing ICU</h4>
<p>ICU is a library for International Components for Unicode and CouchDB relies on it. Let&#8217;s download it from icu-project.org <a href="http://download.icu-project.org/files/icu4c/4.4.1/icu4c-4_4_1-src.tgz" target="_blank">here</a>. Once downloaded, extract the package and move into the sources folder and change some permissions before building the code:</p>
<p><span style="color: #008000;">tar -xzvf icu4c-4_4_1-src.tgz</span></p>
<p><span style="color: #008000;">cd icu/source</span></p>
<p><span style="color: #008000;">chmod +x runConfigureICU configure install-sh</span></p>
<p><span style="color: #008000;">./runConfigreICU -h <span style="color: #000000;">(select the suffix for your OS and and supply it as argument to runConfigureICU, eg: ./runConfigureICU MacOS) </span></span></p>
<p><span style="color: #008000;">make</span></p>
<p><span style="color: #008000;">sudo make install</span></p>
<h4>Installing Erlang</h4>
<p>Erlang is the language used to build CouchDB, and you&#8217;ll have to install it if it&#8217;s not yet present. Download Erlang <a href="http://www.erlang.org/download/otp_src_R14A.tar.gz" target="_self">version 14A</a> (latest as of this writing) from erlang.org <a href="http://www.erlang.org/download/otp_src_R14A.tar.gz" target="_blank">here</a> or use wget or curl as in the steps below.<br />
<span style="color: #008000;">cd /tmp</span><br />
<span style="color: #008000;">wget http://www.erlang.org/download/otp_src_R14A.tar.gz</span><br />
<span style="color: #008000;">tar -xzvf otp_src_R14A.tar.gz</span><br />
<span style="color: #008000;">cd otp_src_R14A</span><br />
<span style="color: #008000;">./configure &#8211;enable-hipe &#8211;enable-smp-support &#8211;enable-threads <span style="color: #000000;">(</span>&#8211;enable-darvin-universal <span style="color: #000000;">for Mac)</span></span><br />
<span style="color: #008000;">make</span><br />
<span style="color: #008000;">sudo make install</span></p>
<h4>Installing CouchDB</h4>
<p>Now finally we&#8217;re ready to install CouchDB.</p>
<p><span style="color: #008000;">cd /tmp</span></p>
<p><span style="color: #008000;">wget http://www.apache.org/dyn/closer.cgi?path=/couchdb/0.11.2/apache-couchdb-0.11.2.tar.gz</span></p>
<p><span style="color: #008000;">tar -xzvf apache</span></p>
<p><span style="color: #008000;">cd apache-couchdb-0.11.2</span></p>
<p><span style="color: #008000;">./configure</span></p>
<p><span style="color: #008000;">make</span></p>
<p><span style="color: #008000;">sudo make install</span></p>
<p><span style="color: #008000;">sudo couchdb start</span></p>
<h4>Testing our CouchDB installation</h4>
<p>Besides the countless client libraries written in almost any language, we can simply use Telnet to create a database and do some basic data manipulation to test our installation.</p>
<p><span style="color: #008000;">telnet localhost 5984</span></p>
<p>If there are no errors and you get a response like below, you&#8217;re all set.</p>
<p><span style="color: #008000;"> Trying 127.0.0.1&#8230;<br />
Connected to localhost.<br />
Escape character is &#8216;^]&#8217;.</span></p>
<p>A good introduction to CouchDB&#8217;s commands can be found <a href="http://wiki.apache.org/couchdb/CouchIn15Minutes" target="_blank">here</a>.</p>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://www.itecsoftware.com/install-and-use-couchdb-with-json-and-map-reduce/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to find duplicate rows in a MySQL database table</title>
		<link>http://www.itecsoftware.com/how-to-find-duplicate-rows-in-a-mysql-database-table?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-find-duplicate-rows-in-a-mysql-database-table</link>
		<comments>http://www.itecsoftware.com/how-to-find-duplicate-rows-in-a-mysql-database-table#comments</comments>
		<pubDate>Thu, 22 Apr 2010 23:19:28 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[duplicate rows]]></category>
		<category><![CDATA[query]]></category>

		<guid isPermaLink="false">http://articles.itecsoftware.com/?p=364</guid>
		<description><![CDATA[<a href="http://www.itecsoftware.com/how-to-find-duplicate-rows-in-a-mysql-database-table" title="How to find duplicate rows in a MySQL database table"></a>I&#8217;ve been asked the question &#8220;How can I return duplicate rows only from a MySQL db table&#8221; so many times already, that I&#8217;ve decided to post it here in a short article. It is not something intuitive or readily available &#8230;<p class="read-more"><a href="http://www.itecsoftware.com/how-to-find-duplicate-rows-in-a-mysql-database-table">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://www.itecsoftware.com/how-to-find-duplicate-rows-in-a-mysql-database-table" title="How to find duplicate rows in a MySQL database table"></a><!-- google_ad_section_start --><p>I&#8217;ve been asked the question &#8220;How can I return duplicate rows only from a MySQL db table&#8221; so many times already, that I&#8217;ve decided to post it here in a short article.</p>
<p>It is not something intuitive or readily available (at least it seems), but the solution is short and very simple.</p>
<p>While this query:</p>
<pre><span style="color: #008000;">SELECT DISTINCT column1
FROM table1</span></pre>
<p>gives us all records without the duplicates, this one returns only the duplicate ones:</p>
<pre>
<pre><span style="color: #008000;">SELECT DISTINCT column1
FROM table1
GROUP BY column1
HAVING COUNT(column1) &gt; 1</span></pre>
</pre>
<p>And by increasing the having count, you can retrieve records with multiple occurrences.</p>
<pre></pre>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://www.itecsoftware.com/how-to-find-duplicate-rows-in-a-mysql-database-table/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL &#8211; How To Analyze, Repair and Optimize all Tables</title>
		<link>http://www.itecsoftware.com/mysql-how-to-analyze-repair-and-optimize-all-tables?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=mysql-how-to-analyze-repair-and-optimize-all-tables</link>
		<comments>http://www.itecsoftware.com/mysql-how-to-analyze-repair-and-optimize-all-tables#comments</comments>
		<pubDate>Mon, 02 Nov 2009 18:14:10 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Useful Stuff]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[analyze table]]></category>
		<category><![CDATA[mysqlcheck]]></category>
		<category><![CDATA[optimize]]></category>
		<category><![CDATA[repair table]]></category>

		<guid isPermaLink="false">http://articles.itecsoftware.com/?p=319</guid>
		<description><![CDATA[<a href="http://www.itecsoftware.com/mysql-how-to-analyze-repair-and-optimize-all-tables" title="MySQL - How To Analyze, Repair and Optimize all Tables"></a>Ever come across a situation, where you&#8217;d like to check all tables in a database and have them all repaired and optimized? My guess is yes. In case you didn&#8217;t know, there is a helpful MySQL utility called mysqlcheck, available &#8230;<p class="read-more"><a href="http://www.itecsoftware.com/mysql-how-to-analyze-repair-and-optimize-all-tables">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://www.itecsoftware.com/mysql-how-to-analyze-repair-and-optimize-all-tables" title="MySQL - How To Analyze, Repair and Optimize all Tables"></a><!-- google_ad_section_start --><p>Ever come across a situation, where you&#8217;d like to check all tables in a database and have them all repaired and optimized? My guess is yes.</p>
<p>In case you didn&#8217;t know, there is a helpful MySQL utility called mysqlcheck, available as of version 3.23.38. It does exactly what we need.</p>
<p>To check all tables in all databases for corruption and errors and also fix them in one go, this is your command:</p>
<p><span style="color: #003300;"><em><span style="color: #008000;">mysqlcheck -u username -p password  &#8211;check &#8211;optimize &#8211;auto-repair &#8211;all-databases</span></em></span></p>
<p>mysqlcheck executes statements like CHECK TABLE, REPAIR TABLE, ANALYZE TABLE, and OPTIMIZE TABLE and chooses the best statements for any given operation and storage engine.</p>
<p>Note that the operations complete a lot faster if you can afford to to disable any external services, especially if your database is large.</p>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://www.itecsoftware.com/mysql-how-to-analyze-repair-and-optimize-all-tables/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to install MySQL Server, PHP and Apache on a Mac</title>
		<link>http://www.itecsoftware.com/how-to-install-mysql-server-php-and-apache-on-a-mac?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-install-mysql-server-php-and-apache-on-a-mac</link>
		<comments>http://www.itecsoftware.com/how-to-install-mysql-server-php-and-apache-on-a-mac#comments</comments>
		<pubDate>Sat, 24 Oct 2009 19:39:50 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[Mac]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Snow Leopard]]></category>

		<guid isPermaLink="false">http://articles.itecsoftware.com/?p=301</guid>
		<description><![CDATA[<a href="http://www.itecsoftware.com/how-to-install-mysql-server-php-and-apache-on-a-mac" title="How to install MySQL Server, PHP and Apache on a Mac"></a>These instructions lead you thru the installation of the latest LAMP Stack on MacOS X Snow Leopard. 1 &#8211; Download the installation image from MySQL website here. Then double-click to mount and open the disk image. 2 &#8211; Install MySQL &#8230;<p class="read-more"><a href="http://www.itecsoftware.com/how-to-install-mysql-server-php-and-apache-on-a-mac">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://www.itecsoftware.com/how-to-install-mysql-server-php-and-apache-on-a-mac" title="How to install MySQL Server, PHP and Apache on a Mac"></a><!-- google_ad_section_start --><p>These instructions lead you thru the installation of the latest LAMP Stack on MacOS X Snow Leopard.</p>
<p>1 &#8211; Download the installation image from MySQL website <a href="http://dev.mysql.com/downloads/mysql/5.1.html#macosx-dmg" target="_blank">here</a>. Then double-click to mount and open the disk image.</p>
<p>2 &#8211; Install MySQL Server by double clicking the package &#8220;mysql-5.1.*****.pkg&#8221; and follow the menu, accepting the default values, unless you want to change something and know exactly what you&#8217;re doing.</p>
<p>3 &#8211; Install MySQL Startup Item by double-clicking the package &#8220;MySQLStartupitem.pkg&#8221; and follow the menu.</p>
<p>4 &#8211; Install MySQL Preference Pane by double-clicking the file &#8220;MySQL.prefPane&#8221; and follow the menu. This item will simplify the management of your SQL Server. You can now use the &#8220;System Preferences&#8221; panel to start and stop the database server.</p>
<p>5 &#8211; Enable the php module in your apache config file. You might know that Snow Leopard already ships with Apache 2.2 and PHP 5.3, but it needs a couple of tweaks to make it work smoothly. So, open /etc/apache2/httpd.conf and search for &#8220;php5_module&#8221;. Remove the comment (#) in front of the line, save and close the file, then restart apache (sudo apachectl restart)</p>
<p><span id="more-301"></span></p>
<p>6 &#8211; Testing Apache/PHP. Let&#8217;s create an info file so we know what we got. Navigate to /Library/WebServer/Documents and create a file called phpinfo.php. Put the following line into the file, save and close. &#8220;&lt;?php phpinfo(); ?&gt;&#8221;. Now open your favorite browser and hit it (http://localhost/phpinfo.php). You should see a page like the one below, which shows you configuration details, modules enabled and other useful information.</p>
<p><img class="size-medium wp-image-307  alignleft" style="margin: 10px;" title="php-info-page" src="http://www.itecsoftware.com/wp-content/uploads/2009/10/php-info-page-300x195.png" alt="PHP Info Page" width="300" height="195" /></p>
<p>7 &#8211; There is no php.ini out of the box (as you may have discovered by looking at the phpinfo page), but there is a sample file called &#8220;php.ini.default&#8221; which we&#8217;re going to use. Copy this file and save it as php.ini.</p>
<p>8 &#8211; Set the default time zone. As PHP 5.3 requires the timezone to be set, let&#8217;s do this inside php.ini, so we don&#8217;t have to worry about it anymore. You can always override it in your application&#8217;s bootstrap, if needed. Open /etc/php.ini and search for &#8220;[Date]&#8220;. Uncomment the line &#8220;date.timezone = &#8221; and add your timezone. Check the <a href="http://www.php.net/manual/en/timezones.php" target="_blank">php manual</a> for acceptable values. (example: date.timezone = &#8216;America/Los Angeles&#8217;)</p>
<p>And that&#8217;s it. You should now have a fully functional LAMP stack with Apache, PHP and MySQL server.</p>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://www.itecsoftware.com/how-to-install-mysql-server-php-and-apache-on-a-mac/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Setup MySQL Replication the easy way</title>
		<link>http://www.itecsoftware.com/setup-mysql-replication-the-easy-way?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=setup-mysql-replication-the-easy-way</link>
		<comments>http://www.itecsoftware.com/setup-mysql-replication-the-easy-way#comments</comments>
		<pubDate>Fri, 14 Aug 2009 18:53:53 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[master]]></category>
		<category><![CDATA[replication]]></category>
		<category><![CDATA[slave]]></category>

		<guid isPermaLink="false">http://articles.itecsoftware.com/?p=216</guid>
		<description><![CDATA[<a href="http://www.itecsoftware.com/setup-mysql-replication-the-easy-way" title="Setup MySQL Replication the easy way"></a>1. Configure the Master We will need to modify a file called my.cnf, which is the main configuration file for mysql. On most systems it&#8217;s located in /etc/ or /etc/mysql/ and it contains all important configuration data. First, let&#8217;s ensure &#8230;<p class="read-more"><a href="http://www.itecsoftware.com/setup-mysql-replication-the-easy-way">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://www.itecsoftware.com/setup-mysql-replication-the-easy-way" title="Setup MySQL Replication the easy way"></a><!-- google_ad_section_start --><p><span style="text-decoration: underline;"><strong>1. Configure the Master</strong></span></p>
<p>We will need to modify a file called <em>my.cnf</em>, which is the main configuration file for mysql. On most systems it&#8217;s located in /etc/ or /etc/mysql/ and it contains all important configuration data.</p>
<p>First, let&#8217;s ensure that networking is enabled and mysql listens on all, or at least the client&#8217;s IP addresses. We also have to tell mysql what file to write the logs to and from which databases to keep logging, so that the Slave can pick up the changes. And finally we need to assign a unique ID to the Master.</p>
<p>All this info is contained within the following lines in your my.cnf file. Please note that the position of these entries can be spread throughout the file, so you might have to search for each of them.</p>
<address><span style="color: #008000;">#skip-networking</span></address>
<address><span style="color: #008000;"># bind-address = xxx.xxx.xxx.xxx (this can be the Slave&#8217;s IP address. if you&#8217;re not sure, leave it commented out)</span></address>
<address><span style="color: #008000;">log-bin = /var/log/mysql/mydatabase-bin.log</span></address>
<address><span style="color: #008000;">server-id = 1</span></address>
<address> </address>
<p><span style="color: #000000;">Restart the server. Then log into mysql and create a user with replication privileges:</span></p>
<address><span style="color: #008000;">GRANT REPLICATION SLAVE ON *.* TO &#8216;slave_user&#8217;@'%&#8217; IDENTIFIED BY &#8216;&lt;password&gt;&#8217;;<br />
FLUSH PRIVILEGES; </span></address>
<address><span style="color: #008000;">USE mydatabase;</span></address>
<p>The next 3 steps is to lock all tables on the database, take a backup and get the replication sequence ID. We&#8217;ll use the backup later on the Slave to establish the baseline, and tell it to start replication starting from the sequence ID.</p>
<p><span id="more-216"></span></p>
<p>If you&#8217;re performing this action on a high volume production system, I&#8217;d recommend to plan these next steps carefully, as the db will be locked for writing during the backup process.</p>
<address><span style="color: #003300;"> <span style="color: #008000;">FLUSH TABLES WITH READ LOCK;<br />
SHOW MASTER STATUS; </span></span></address>
<p><span style="color: #003300;"><span style="color: #000000;">Write down the &#8220;Position&#8221; number, it&#8217;s the sequence ID and the bin log file. Since the tables are locked, you&#8217;ll need to open a second terminal and log into mysql and perform the backup:</span></span></p>
<address><span style="color: #008000;">mysqldump -u root -p&lt;password&gt; &#8211;opt mydatabase | gzip &gt; mydatabasedump.sql.gz</span></address>
<p>Once the backup is finished, unlock the tables in the first terminal.</p>
<address><span style="color: #008000;">UNLOCK TABLES;</span></address>
<address></address>
<p>Whew, we&#8217;re done with the Master. Wasn&#8217;t that hard, was it? Now on to the Slave.</p>
<div style="float: left; width: 250px; margin-right: 20px;"><script type="text/javascript">// <![CDATA[
    google_ad_client = "pub-5075229468189091"; /* 250x250, created 8/18/09 */ google_ad_slot = "1952402743"; google_ad_width = 250; google_ad_height = 250;
// ]]&gt;</script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">
</script></div>
<p><strong><span style="text-decoration: underline;">2. Configure the Slave</span></strong></p>
<p>You&#8217;ll have to copy the backup file to the Slave server and extract it (gzip -d). On the Slave, let&#8217;s first create the database and restore the dump we took from the Master.</p>
<p>After loging into mysql from the terminal:</p>
<address><span style="color: #008000;">CREATE DATABASE mydatabase;</span></address>
<address><span style="color: #008000;">exit;</span></address>
<address><span style="color: #008000;">mysql -u&lt;user&gt; -p&lt;password&gt; mydatabase &lt; mydatabasedump.sql;</span></address>
<p>Then we&#8217;ll go on to configure my.cnf on the Slave. As I stated earlier, the position of these entries can be spread throughout the file, so you might have to search for each of them or they might not even be present, so you have to add them.</p>
<address><span style="color: #008000;">server-id=2<br />
replicate-do-db=mydatabase</span></address>
<p><span style="text-decoration: underline;"><span style="color: #000000;"><strong>3. setup parameters and start replication</strong></span></span></p>
<p>Restart MySQL, login to mysql and stop the Slave. You now will need the info you wrote down during the &#8220;SHOW MASTER STATUS&#8221; command.</p>
<address> <span style="color: #008000;">SLAVE STOP;</span></address>
<address><span style="color: #008000;">CHANGE MASTER TO MASTER_HOST=&#8217;IP address of Master&#8217;, MASTER_USER=&#8217;&lt;user&gt;&#8217;, MASTER_PASSWORD=&#8217;&lt;password&gt;&#8217;, MASTER_LOG_FILE=&#8217;&lt;the log bin file&gt;&#8217;, MASTER_LOG_POS=&lt;the sequence ID&gt;; </span></address>
<p>Example: CHANGE MASTER TO MASTER_HOST=&#8217;192.168.1.1&#8242;, MASTER_USER=&#8217;slave_user&#8217;, MASTER_PASSWORD=&#8217;1234&#8242;, MASTER_LOG_FILE=&#8217;mysql-bin.001&#8242;, MASTER_LOG_POS=256;</p>
<p>Finally, we start the Slave with the new settings and get replication started. Still from the terminal, logged in to mysql:</p>
<address><span style="color: #008000;">START SLAVE;</span></address>
<p>That&#8217;s all there is to it. There are commands like &#8220;SHOW SLAVE STATUS&#8221; that let&#8217;s you check if replication is working.</p>
<p>Update:</p>
<p>If you have problems getting &#8220;Slave_IO_Running&#8221; to &#8220;Yes&#8221; state, you might have to flush the tables on the slave, like this:</p>
<p><span style="color: #003300;"><em>STOP SLAVE;</em></span></p>
<p><span style="color: #003300;"><em>FLUSH TABLES WITH READ LOCK;</em></span></p>
<p><span style="color: #003300;"><em>UNLOCK TABLES;</em></span></p>
<p><span style="color: #003300;"><em>START SLAVE;</em></span></p>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://www.itecsoftware.com/setup-mysql-replication-the-easy-way/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Nginx and memcached module</title>
		<link>http://www.itecsoftware.com/nginx-and-memcached-module?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=nginx-and-memcached-module</link>
		<comments>http://www.itecsoftware.com/nginx-and-memcached-module#comments</comments>
		<pubDate>Fri, 17 Jul 2009 20:31:35 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[Shell Scripting]]></category>
		<category><![CDATA[Useful Stuff]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[memcache]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://articles.itecsoftware.com/?p=148</guid>
		<description><![CDATA[With nginx memcache module, we serve more pages faster with less hardware. It's a nobrainer.<p class="read-more"><a href="http://www.itecsoftware.com/nginx-and-memcached-module">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://www.itecsoftware.com/nginx-and-memcached-module" title="Nginx and memcached module"></a><!-- google_ad_section_start --><p><a rel="nofollow" href="http://www.danga.com/memcached/" target="_blank">Memcache</a> is traditionally used as a module inside server side scripts, such as <a rel="nofollow" href="http://www.php.net" target="_blank">PHP</a>, ASP, ColdFusion and others. And it&#8217;s doing a terrific job, as long as it&#8217;s implemented correctly.</p>
<p>But if we look under the hood of the actual <a rel="nofollow" href="http://www.danga.com/memcached/" target="_blank">Memcache</a> application, and I&#8217;m not talking about the PHP or ASP extension, but rather the executable that&#8217;s running as a daemon under linux, for example, it is a rather simple database like application running in memory. Now there are two basic actions that need to be performed to use it, one is writing info into memcache, the other is reading it. In a typical scenario, there are many reads for one write, that&#8217;s the whole point, isn&#8217;t it. But what if we can isolate the reading from the server side scripts, and let a small high speed module do that for us.</p>
<p><span id="more-148"></span></p>
<p>That&#8217;s where <a rel="nofollow" href="http://nginx.net/" target="_blank">Nginx</a> and it&#8217;s <a rel="nofollow" href="http://wiki.nginx.org/NginxHttpMemcachedModule" target="_blank">Memcache Module</a> comes in. We use PHP to fill up the cache and then let Nginx serve that content to the requesting client. According to lead architect Peter Gilg, this configuration is used at <a rel="nofollow" href="http://www.mademan.com/" target="_blank">Mademan.com</a>, a lifestyle site serving up to 1 million pageviews/day.</p>
<p>To be more specific, we&#8217;ll have nginx listen on port 80. If a request comes in, it checks memcache if the requested page is in memory and serves it directly to the client, or sends it to <a rel="nofollow" href="http://apache.org/" target="_blank">Apache</a> (on port 88 for example) to produce the page. At the same time apache inserts the page into memcache, so it&#8217;s available to nginx for the next request.  A sample configuration nginx script would look something like this:</p>
<pre class="code"><a href="http://wiki.nginx.org/NginxHttpCoreModule#server"><span class="kw3">server</span></a> <span class="br0">{</span>
  <a rel="nofollow" href="http://wiki.nginx.org/NginxHttpCoreModule#location"><span class="kw3">location</span></a> / <span class="br0">{</span>
    <a rel="nofollow" href="http://wiki.nginx.org/NginxHttpRewriteModule#set"><span class="kw22">set</span></a> <span class="re0">$memcached_key</span> <span class="re0">$uri</span>;
    <a rel="nofollow" href="http://wiki.nginx.org/NginxHttpMemcachedModule#memcached_pass"><span class="kw20">memcached_pass</span></a>     name:<span class="nu0">11211</span>;
    <a rel="nofollow" href="http://wiki.nginx.org/NginxHttpCoreModule#default_type"><span class="kw3">default_type</span></a>       text/html;
    <a rel="nofollow" href="http://wiki.nginx.org/NginxHttpCoreModule#error_page"><span class="kw3">error_page</span></a>         <span class="nu0">404</span> = /fallback;
  <span class="br0">}</span>

  <a rel="nofollow" href="http://wiki.nginx.org/NginxHttpCoreModule#location"><span class="kw3">location</span></a> = /fallback <span class="br0">{</span>
    <a rel="nofollow" href="http://wiki.nginx.org/NginxHttpProxyModule#proxy_pass"><span class="kw21">proxy_pass</span></a> backend;
  <span class="br0">}</span>
<span class="br0">}</span></pre>
<p><span style="text-decoration: underline;"><strong>Additional Resources:</strong></span> <a rel="nofollow" href="http://nginx.net/" target="_blank">Nginx</a> <a rel="nofollow" href="http://www.danga.com/memcached/" target="_blank">Memcache</a> <a rel="nofollow" href="http://apache.org/" target="_blank">Apache</a><script type="text/javascript"><!--
google_ad_client = "pub-5075229468189091";
google_ad_slot = "2446713154";
google_ad_width = 468;
google_ad_height = 15;
// --></script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script></p>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://www.itecsoftware.com/nginx-and-memcached-module/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Auto Create Thumnails The Easy Way</title>
		<link>http://www.itecsoftware.com/auto-create-thumnails-the-easy-way?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=auto-create-thumnails-the-easy-way</link>
		<comments>http://www.itecsoftware.com/auto-create-thumnails-the-easy-way#comments</comments>
		<pubDate>Sun, 12 Jul 2009 18:43:23 +0000</pubDate>
		<dc:creator>Peter</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[Shell Scripting]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[create tumbnails]]></category>
		<category><![CDATA[imagemagick]]></category>

		<guid isPermaLink="false">http://articles.itecsoftware.com/?p=175</guid>
		<description><![CDATA[<a href="http://www.itecsoftware.com/auto-create-thumnails-the-easy-way" title="Auto Create Thumnails The Easy Way"></a>Ever wondered it there is an easy way to resize your images or quickly create thumbnails from your favorite pictures? Search no more, the awesome little utility ImageMagick does it for you. Install it using your package manager, most of &#8230;<p class="read-more"><a href="http://www.itecsoftware.com/auto-create-thumnails-the-easy-way">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://www.itecsoftware.com/auto-create-thumnails-the-easy-way" title="Auto Create Thumnails The Easy Way"></a><!-- google_ad_section_start --><p>Ever wondered it there is an easy way to resize your images or quickly create thumbnails from your favorite pictures?<br />
Search no more, the awesome little utility ImageMagick does it for you.</p>
<p>Install it using your package manager, most of them should have it in their repository.</p>
<p style="padding-left: 30px;color: #008000;">sudo apt-get install imagemagick</p>
<p>Once installed, this command will create tumbnails for all JPG&#8217;s in the current directory, 200 pixel wide/high on the longest side. Eg. if your image is in landscape layout, it&#8217;ll be 200 pixel wide, in portrait format it&#8217;ll be 200 pixel high.</p>
<p style="padding-left: 30px;color: #008000;">for file in *.jpg ; do convert -resize 200 &#8220;$file&#8221; t&#8221;$file&#8221;; done</p>
<p>That&#8217;s it. Simply change 200 to the size of your liking, or change the extension if your images are in gif, png or any other image format.</p>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://www.itecsoftware.com/auto-create-thumnails-the-easy-way/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: basic
Database Caching 23/25 queries in 0.006 seconds using disk: basic
Object Caching 1214/1214 objects using disk: basic

Served from: www.itecsoftware.com @ 2012-05-19 13:33:41 -->
