<?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>Bit Matrix &#187; MySQL</title>
	<atom:link href="http://blog.bit-matrix.com/tag/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.bit-matrix.com</link>
	<description>Tech. Code. Linux. MySQL. Ones. Zeroes.</description>
	<lastBuildDate>Tue, 31 Aug 2010 01:10:39 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Generate your own Wordpress Permalink without GUIDs from database</title>
		<link>http://blog.bit-matrix.com/2010/03/01/generate-your-own-wordpress-permalink-without-guids-from-database/</link>
		<comments>http://blog.bit-matrix.com/2010/03/01/generate-your-own-wordpress-permalink-without-guids-from-database/#comments</comments>
		<pubDate>Mon, 01 Mar 2010 19:25:31 +0000</pubDate>
		<dc:creator>Bit Matrix</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[guid]]></category>

		<guid isPermaLink="false">http://blog.bit-matrix.com/?p=134</guid>
		<description><![CDATA[If you are generating links to your blog articles via some other mechanism than Wordpress itself you usually have to use the guid database field. This is the unique global indentifier of the post. In reality it is not globally unique but only unique to your blog.
Typically, the guid in the database will look something [...]]]></description>
			<content:encoded><![CDATA[<p>If you are generating links to your blog articles via some other mechanism than Wordpress itself you usually have to use the <b>guid</b> database field. This is the unique global indentifier of the post. In reality it is not globally unique but only unique to your blog.<span id="more-134"></span></p>
<p>Typically, the guid in the database will look something like this:</p>
<blockquote><p>http://blog.bit-matrix.com/?p=2411</p></blockquote>
<p>You can use this perfectly fine but it will hurt your SEO since search sites prefer descriptive links such as:</p>
<blockquote><p>http://blog.bit-matrix.com/2010/02/10/google-buzz-a-privacy-disaster</p></blockquote>
<p>As it turns out, you can easily construct this link from the database yourself. Wordpress will recognize the format of the link and display the appropriate post. The query to construct this is quite simple, all we need is a little date formatting:</p>
<blockquote><p>SELECT CONCAT(DATE_FORMAT(post_date,&#8217;%Y/%m/%d/&#8217;),post_name) AS permalink FROM wp_posts WHERE post_status=&#8217;publish&#8217;;</p></blockquote>
<p>This will return all the published post guid&#8217;s in the following format:</p>
<blockquote><p>2010/02/10/google-buzz-a-privacy-disaster</p></blockquote>
<p>That&#8217;s all!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bit-matrix.com/2010/03/01/generate-your-own-wordpress-permalink-without-guids-from-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL Replication &#8211; Silent Timeout Failure</title>
		<link>http://blog.bit-matrix.com/2009/07/19/mysql-replication-silent-failure/</link>
		<comments>http://blog.bit-matrix.com/2009/07/19/mysql-replication-silent-failure/#comments</comments>
		<pubDate>Mon, 20 Jul 2009 04:19:23 +0000</pubDate>
		<dc:creator>Bit Matrix</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[replication]]></category>

		<guid isPermaLink="false">http://blog.bit-matrix.com/?p=62</guid>
		<description><![CDATA[I have been encountering a strange error that causes MySQL replication to stop working without any errors reported via SHOW SLAVE STATUS. The command reports everything running ok and that the slave is caught up with the master (seconds behind master=0).
However, looking into the running processes via SHOW FULL PROCESSLIST I noticed that the thread [...]]]></description>
			<content:encoded><![CDATA[<p>I have been encountering a strange error that causes MySQL <a title="What is replication?" href="/2008/11/26/what-is-mysql-replication/">replication</a> to stop working without any errors reported via SHOW SLAVE STATUS. The command reports everything running ok and that the slave is caught up with the master (seconds behind master=0).</p>
<p>However, looking into the running processes via SHOW FULL PROCESSLIST I noticed that the thread reading the binary log data from the master has disappeared mysteriously.<br />
<span id="more-62"></span></p>
<p>Normally you should see two threads related to replication running on a slave server under the <em>system user</em>. One for reading the binary log data from the master and the other one for executing fetched data from the relay log:</p>
<pre style="font-size:9px;">
mysql&gt;SHOW FULL PROCESSLIST;
+--------+-------------+---------------------+------+---------+---------+-----------------------------------------------------------------------+-----------------------+
| Id     | User        | Host                | db   | Command | Time    | State                                                                 | Info                  |
+--------+-------------+---------------------+------+---------+---------+-----------------------------------------------------------------------+-----------------------+
|  37550 | system user |                     | NULL | Connect | 5878076 | Waiting for master to send event                                      | NULL                  |
|  37551 | system user |                     | NULL | Connect |       0 | Has read all relay log; waiting for the slave I/O thread to update it | NULL                  |
| 119738 | you         | 127.0.0.1:37540 | NULL | Query   |       0 | NULL                                                                  | SHOW FULL PROCESSLIST |
+--------+-------------+---------------------+------+---------+---------+-----------------------------------------------------------------------+-----------------------+
3 rows in set (0.17 sec)

mysql&gt;
</pre>
<p>Restarting the slave would work for a short while until the same silent failure occurred.</p>
<p>In order to counter this, I looked into the variables related to networking and replication. modified the global variable &#8217;slave_net_timeout&#8217;. The default variable for this is 3600 seconds (ie. 1 hour). The slave timeout sets the number of seconds to wait for the master to send more data before aborting the read. I set it to a short, 10 second period:</p>
<pre>
SET GLOBAL slave_net_timeout=10;
</pre>
<p>This improved the situation and the incidence of replication mysteriously stopping dropped dramatically. Additionally now the slave IO thread would actually stop running which, at least, given an indication that something is wrong.</p>
<p>Overall, the number of these failures dropped to almost zero just as suddenly as they had appeared. This leads me to believe that there might have been something in the network connection between the master and slave servers (in different datacenters) that was causing this.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bit-matrix.com/2009/07/19/mysql-replication-silent-failure/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Running Simple and Effective MySQL Backups</title>
		<link>http://blog.bit-matrix.com/2008/12/09/running-simple-and-effective-mysql-backups/</link>
		<comments>http://blog.bit-matrix.com/2008/12/09/running-simple-and-effective-mysql-backups/#comments</comments>
		<pubDate>Wed, 10 Dec 2008 07:56:53 +0000</pubDate>
		<dc:creator>Bit Matrix</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[replication]]></category>
		<category><![CDATA[restore]]></category>

		<guid isPermaLink="false">http://blog.bit-matrix.com/?p=28</guid>
		<description><![CDATA[We all know that we should backup our data regularly. This is doubly true when it is not our data but our employers data that we are entrusted with. There are two parts to any successful backup strategy: backup and restore. Often, the restore part is left as an exercise to the reader once needed. [...]]]></description>
			<content:encoded><![CDATA[<p>We all know that we should backup our data regularly. This is doubly true when it is not our data but our employers data that we are entrusted with. There are two parts to any successful backup strategy: backup and restore. Often, the restore part is left as an exercise to the reader once needed. I will outline a few tip in this blog for how to make a simple and effective backup processes for a MySQL database.<span id="more-28"></span></p>
<h4>Tip #1: Check the file sizes</h4>
<p><em>&#8220;Why sure boss, I have last night&#8217;s backup right here, it&#8217;s&#8230; 0 bytes!&#8221;</em></p>
<p>While running backups very often is good it can fill up your backup drives rather quick. The solution is to consolidate your backup at the end of each day. Delete all the previous backups for that day and only keep the latest. And always check the file sizes of your backups! Generally they should always increase and should definitely not be zero bytes!</p>
<h4>Tip #2: Run backups off a replicated slave</h4>
<p>If you are making a backup of the database while someone if trying to access it they will have to wait until the backup is done before they can commit any writes. This is annoying to the user and the larger your database gets, the more they&#8217;ll have to wait. A common solution is to setup a <a title="What is replication?" href="/2008/11/26/what-is-mysql-replication/">replicated slave</a> and make the backups from that machine instead of the master database. This way the client is unaffected. If course, make sure your replication slave is running when using that server for backups.</p>
<h4>Tip #3: Dump a single table at a time</h4>
<p>If you are making backups by dumping data into an SQL file (which would be the most common way) the best practice is to dump a single table at a time. There are a few advantages to this. Firstly, if you need to restore data from only one table at a later data you can just import that SQL file instead of trawling through the entire database dump. This makes the restoring job much simpler. Secondly, it results in smaller files which are easier to manage.</p>
<h4>Conclusion</h4>
<p>Using these tips will result in simple and transparent backup system which is easy to monitor and, most importantly, is actually useful when it comes to restoring data.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bit-matrix.com/2008/12/09/running-simple-and-effective-mysql-backups/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL 5.1 Released GA</title>
		<link>http://blog.bit-matrix.com/2008/12/01/mysql-51-released-ga/</link>
		<comments>http://blog.bit-matrix.com/2008/12/01/mysql-51-released-ga/#comments</comments>
		<pubDate>Mon, 01 Dec 2008 18:11:01 +0000</pubDate>
		<dc:creator>Bit Matrix</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[5.1]]></category>
		<category><![CDATA[database]]></category>

		<guid isPermaLink="false">http://blog.bit-matrix.com/?p=21</guid>
		<description><![CDATA[MySQL version 5.1 was released today as GA (Generally Available) which means that you can feel safe in using it in a production environment. Of course, any DBA worth their weight in salt should always test any new version personally before flipping the proverbial switch. If there is no need to upgrade (you don&#8217;t need [...]]]></description>
			<content:encoded><![CDATA[<p>MySQL version 5.1 was released today as GA (Generally Available) which means that you can feel safe in using it in a production environment. Of course, any DBA worth their weight in salt should always test any new version personally before flipping the proverbial switch. If there is no need to upgrade (you don&#8217;t need the new features) then there is no reason to take the risk. As MySQL founder Monty <a href="http://monty-says.blogspot.com/2008/11/oops-we-did-it-again-mysql-51-released.html">points out on his blog</a>, no release is perfect and 5.1 still has some bugs left in this release which, he feels, should have been addressed a while ago.<span id="more-21"></span></p>
<p>Here are some of the highlight new features in MySQL 5.1:</p>
<ul>
<li> Federated tables</li>
<li> Partitioning</li>
<li> Row-based replication</li>
<li> Event scheduler</li>
<li> MySQL Cluster updated and now available as separate product</li>
</ul>
<p>For a more complete list and details see the MySQL 5.1 <a href="http://dev.mysql.com/doc/refman/5.1/en/mysql-nutshell.html">official new features page</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bit-matrix.com/2008/12/01/mysql-51-released-ga/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What is MySQL replication?</title>
		<link>http://blog.bit-matrix.com/2008/11/26/what-is-mysql-replication/</link>
		<comments>http://blog.bit-matrix.com/2008/11/26/what-is-mysql-replication/#comments</comments>
		<pubDate>Thu, 27 Nov 2008 08:12:41 +0000</pubDate>
		<dc:creator>Bit Matrix</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[replication]]></category>

		<guid isPermaLink="false">http://blog.bit-matrix.com/?p=12</guid>
		<description><![CDATA[Replication is a feature of MySQL that allows one database server to mirror the data on another database server by executing the same queries. There are more complicated ways of setting it up but basic replication involves one master server and one slave server.
The master server is typically being used to execute reads and writes [...]]]></description>
			<content:encoded><![CDATA[<p>Replication is a feature of MySQL that allows one database server to mirror the data on another database server by executing the same queries. There are more complicated ways of setting it up but basic replication involves one master server and one slave server.<span id="more-12"></span></p>
<p>The master server is typically being used to execute reads and writes of the data while the slave (which started with an exact copy of the master&#8217;s data) duplicates the writes and thus maintains data that is identical to the master. Replication can be setup on several levels: all databases on a server, selected databases or even selected tables.</p>
<h4>Usage Scenarios</h4>
<p>Replication can be a very powerful tool in various scenarios:</p>
<ul>
<li>When distributing load, you can use multiple slave servers to read data from while only writing to the one master server.</li>
<li>A slave server can be used as a hot standby in case of master failure.</li>
<li>Slave servers can be used to perform operations that would typically result in degraded performance on the master, such as executing backups or running large queries for reports.</li>
</ul>
<h4>Advantages and Feature</h4>
<p>A major feature of replication is the easy with which it can be implemented in a working environment. Replication is also fairly hands-free when it comes to maintenance (a few typical problems not withstanding, see below).</p>
<p>The simple operation allows for a changing and evolving setup so your replicated database solution can grow with you. Need more power? Add more read-only slaves. This will scale quite well for most solutions and depending on your particular usage. Naturally the more read-heavy your problem, the better use you can make of replicated read-only slaves to scale. Fortunately most database problems are read-heavy.</p>
<p>Another feature of replication is that it is asynchronous, i.e. the master and slave do not need to be constantly connected. When a connection is established, the slave server will &#8220;catch up&#8221; to the master. This helps make any solution implemented with replication pretty robust as long as one keeps in mind that the slave servers can and do lag behind the master on occasion &#8211; as we see in the next paragraph.</p>
<h4>Potential Issues</h4>
<p>However, replication is not without its share of problems.</p>
<p>For example, in implementing some of the above uses of replication one has to be weary of lag between the master and the slave. Either due to the slave&#8217;s &#8220;slow&#8221; connection speeds, the slower speed of the slave server or high load on the slave server it can start lagging behind the master. This is the result of the asynchronous nature of replication, while a definite and necessary feature, requires that we keep an eye on this potential problem. In normal operation with similarly matches master and slave servers, replication can be considered instantaneous (particularly on fast local networks).</p>
<p>A second drawback of replication can occur when the data on the slave becomes corrupted. A scenario like this can occur when servers are powered off unexpectedly or the server&#8217;s hard drives develop problems. While not a common occurrence, if the data is corrupted beyond salvation, the replication process needs to be started from scratch. This requires &#8220;pausing&#8221; the master server while a snapshot of its data is taken. After this the data is copied over to the slave and replication is restarted from the master&#8217;s current position.</p>
<p>Most issues due to interrupted replication are solved fairly quickly by restarting the replication and possibly skipping over the first duplicate record in the binary log. More detail about that can be found in <a title="MySQL Replication Error 1201" href="/2008/11/19/mysql-replication-error-1201-could-not-initialize-master-info-structure/">this post</a>.</p>
<h4>Conclusion</h4>
<p>Replication is a powerful feature of MySQL that is being used daily to provide high scalability and performance while keeping the entry cost low in terms of administration and setup time.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bit-matrix.com/2008/11/26/what-is-mysql-replication/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL Replication ERROR 1201: Could not initialize master info structure&#8230;</title>
		<link>http://blog.bit-matrix.com/2008/11/19/mysql-replication-error-1201-could-not-initialize-master-info-structure/</link>
		<comments>http://blog.bit-matrix.com/2008/11/19/mysql-replication-error-1201-could-not-initialize-master-info-structure/#comments</comments>
		<pubDate>Thu, 20 Nov 2008 07:36:13 +0000</pubDate>
		<dc:creator>Bit Matrix</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[replication]]></category>

		<guid isPermaLink="false">http://blog.bit-matrix.com/?p=4</guid>
		<description><![CDATA[I have noticed strange behavior with MySQL version 5 and replication. I manage several MySQL database servers. The setup is simple, one master and two replication slaves acting as backups. The master server version is 5.0.22-log and the two slaves are 5.0.51a and 5.0.45.
When the replication gets interrupted (either via a clean server shutdown or [...]]]></description>
			<content:encoded><![CDATA[<p>I have noticed strange behavior with MySQL version 5 and <a title="What is replication?" href="/2008/11/26/what-is-mysql-replication/">replication</a>. I manage several MySQL database servers. The setup is simple, one master and two replication slaves acting as backups. The master server version is 5.0.22-log and the two slaves are 5.0.51a and 5.0.45.</p>
<p>When the replication gets interrupted (either via a clean server shutdown or a forced one), replication refuses to restart citing the following error:</p>
<blockquote><p>ERROR 1201: Could not initialize master info structure, more error messages can be found in the MySQL error log</p></blockquote>
<p><span id="more-4"></span></p>
<p>The master.info file is present in the data directory and has all the required information in it but MySQL refuses to use it. Searching on the net did not yield anything definitive.</p>
<p>The simplest way to restart replication from this point is to re-enter the master.info data manually. Do the following:</p>
<ol>
<li>STOP SLAVE</li>
<li>RESET SLAVE</li>
<li>CHANGE MASTER TO MASTER_HOST=&#8217;your_master&#8217;, MASTER_USER=&#8217;your_login&#8217;, MASTER_PASSWORD=&#8217;your_password&#8217;, MASTER_LOG_FILE=&#8217;log_file&#8217;, MASTER_LOG_POS=log_position</li>
<li>START SLAVE</li>
</ol>
<p>At this point you want to execute &#8216;SHOW SLAVE STATUS&#8217; and check to see if everything is running. Most times MySQL will stop since it tried to replay a duplicate record from the logs. We need to tell MySQL to skip that record and continue:</p>
<ol>
<li>SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1</li>
<li>START SLAVE</li>
</ol>
<p>That should get replication up and running again.</p>
<p>What is interesting to note is that, under the same circumstances, my MySQL 4 servers had no problems continuing replication. In any case, don&#8217;t forget to run regular <a title="Running simple and effective MySQL backups" href="/2008/12/09/running-simple-and-effective-mysql-backups/">backups of your database</a>. <img src='http://blog.bit-matrix.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bit-matrix.com/2008/11/19/mysql-replication-error-1201-could-not-initialize-master-info-structure/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
	</channel>
</rss>
