<?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>Blog dot Melimato dot Com &#187; mysql</title>
	<atom:link href="http://blog.melimato.com/category/server/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.melimato.com</link>
	<description>Those things we do</description>
	<lastBuildDate>Fri, 29 Jul 2011 09:24:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Restoring readline capabilities of Ubuntu&#8217;s 9.10 (Karmic Koala) MySQL client</title>
		<link>http://blog.melimato.com/restoring-readline-capabilities-of-ubuntus-9-10-karmic-koala-mysql-client/</link>
		<comments>http://blog.melimato.com/restoring-readline-capabilities-of-ubuntus-9-10-karmic-koala-mysql-client/#comments</comments>
		<pubDate>Thu, 24 Dec 2009 11:58:58 +0000</pubDate>
		<dc:creator>pedro</dc:creator>
				<category><![CDATA[mysql]]></category>
		<category><![CDATA[mysql command line]]></category>
		<category><![CDATA[readline]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://blog.melimato.com/?p=227</guid>
		<description><![CDATA[I recently updated to the newest version, 9.10 AKA Karmic Koala and I love it. It&#8217;s fast and everything works perfectly. Or nearly everything&#8230; The one thing that really annoyed me in this version was the MySQL terminal. All of a sudden after the upgrade ctrl+r for reverse search didn&#8217;t work anymore. And there was [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.melimato.com%2Frestoring-readline-capabilities-of-ubuntus-9-10-karmic-koala-mysql-client%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.melimato.com%2Frestoring-readline-capabilities-of-ubuntus-9-10-karmic-koala-mysql-client%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>I recently updated to the <a href="http://www.ubuntu.com/">newest version, 9.10 AKA Karmic Koala</a> and I love it. It&#8217;s fast and everything works perfectly. Or nearly everything&#8230;</p>
<p><span id="more-227"></span></p>
<p>The one thing that really annoyed me in this version was the MySQL terminal. All of a sudden after the upgrade ctrl+r for reverse search didn&#8217;t work anymore. And there was more&#8230;delete didn&#8217;t work either and esc+backspace was behaving weirdly too. Unfortunately I did not have time to look for a solution because of my work load. But then xmas came and here I am, stuck at home with the family, giving me a lot of time to research about those things that were very low on my priorities list. And I found a solution!</p>
<p>It seems that Ubuntu replaced <a href="http://utopia.knoware.nl/~hlub/uck/rlwrap/">libreadline</a> with <a href="http://thrysoee.dk/editline/">libedit</a>. And <a href="http://utopia.knoware.nl/~hlub/uck/rlwrap/">readline</a> is the library that provides all those cool command line capabilities. So let&#8217;s enable it again, but instead of compiling the whole thing again, let&#8217;s just use a wrapper, the <a href="http://freshmeat.net/projects/rlwrap/">readline wrapper</a>!</p>
<p>First, let&#8217;s install it:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> rlwrap</pre></div></div>

<p>That&#8217;s it! Now all we need to do is to start mysql command line interface through rlwrap:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">rlwrap <span style="color: #660033;">-a</span> mysql <span style="color: #660033;">-uUSER</span> <span style="color: #660033;">-pPASSWORD</span> DBNAME</pre></div></div>

<p>To make things easier, let&#8217;s create an alias in our bashrc file.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">vi</span> ~<span style="color: #000000; font-weight: bold;">/</span>.bashrc</pre></div></div>

<p>And add the alias:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">mysql</span>=<span style="color: #ff0000;">'rlwrap -a mysql'</span></pre></div></div>

<p>Credit: <a href="http://ubuntuforums.org/showthread.php?t=1147183">http://ubuntuforums.org/showthread.php?t=1147183</a></p>
<div id="wherego_related"> </div>]]></content:encoded>
			<wfw:commentRss>http://blog.melimato.com/restoring-readline-capabilities-of-ubuntus-9-10-karmic-koala-mysql-client/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Keeping directories in sync with unison</title>
		<link>http://blog.melimato.com/keeping-directories-in-sync-with-unison/</link>
		<comments>http://blog.melimato.com/keeping-directories-in-sync-with-unison/#comments</comments>
		<pubDate>Fri, 08 May 2009 23:24:09 +0000</pubDate>
		<dc:creator>pedro</dc:creator>
				<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[sync]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[rsync]]></category>
		<category><![CDATA[unison]]></category>

		<guid isPermaLink="false">http://blog.melimato.com/?p=104</guid>
		<description><![CDATA[As opposed to rsync, unison is a two way file synchronizer. Similar to MySQL&#8217;s master to master replication. To set it up in Ubuntu (Intrepid) keep on reading&#8230; 1. Install unison on both servers apt-get install unison 2. Create a script to add to crontab to call unison periodically unison -numericids -owner -silent -times -contactquietly [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.melimato.com%2Fkeeping-directories-in-sync-with-unison%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.melimato.com%2Fkeeping-directories-in-sync-with-unison%2F&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>As opposed to rsync, unison is a two way file synchronizer. Similar to MySQL&#8217;s master to master replication. To set it up in Ubuntu (Intrepid) keep on reading&#8230;</p>
<p><span id="more-104"></span></p>
<p>1. Install unison on both servers</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> unison</pre></div></div>

<p>2. Create a script to add to crontab to call unison periodically</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">unison <span style="color: #660033;">-numericids</span> <span style="color: #660033;">-owner</span> <span style="color: #660033;">-silent</span> <span style="color: #660033;">-times</span> <span style="color: #660033;">-contactquietly</span> <span style="color: #660033;">-batch</span> <span style="color: #660033;">-auto</span> <span style="color: #660033;">-log</span> <span style="color: #660033;">-logfile</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>unison.log profile_file <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span></pre></div></div>

<p>3. Create the above mentioned profile file on ~/.unison/profile_file.prf</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">root = <span style="color: #c20cb9; font-weight: bold;">ssh</span>:<span style="color: #000000; font-weight: bold;">//</span>server_ip<span style="color: #000000; font-weight: bold;">//</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>root<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">dir</span>
root = <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>root<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">dir</span>
ignore = Regex .<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>cache<span style="color: #000000; font-weight: bold;">|</span>Cache<span style="color: #000000; font-weight: bold;">|</span>te?mp<span style="color: #000000; font-weight: bold;">|</span>logs?<span style="color: #7a0874; font-weight: bold;">&#41;</span>.<span style="color: #000000; font-weight: bold;">*</span> <span style="color: #666666; font-style: italic;"># ignore log and cache files</span></pre></div></div>

<p>That&#8217;s it! Now add the following line to your crontab to execute it every 5min</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">*/</span><span style="color: #000000;">5</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>my_unison_script.sh</pre></div></div>

<p>After a few days of running this I found that sometimes one unison execution would overlap another. To resolve this I found a little tool called <a href="http://unixwiz.net/tools/lockrun.html">lockrun</a></p>
<p>To get it to work I did:</p>
<p>1. Download the source code from the official <a href="http://unixwiz.net/tools/lockrun.c">lockrun website</a></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>unixwiz.net<span style="color: #000000; font-weight: bold;">/</span>tools<span style="color: #000000; font-weight: bold;">/</span>lockrun.c</pre></div></div>

<p>2. Build/install as shown in <a href="http://unixwiz.net/tools/lockrun.html">http://unixwiz.net/tools/lockrun.html</a></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">gcc</span> lockrun.c <span style="color: #660033;">-o</span> lockrun
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">cp</span> lockrun <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>3. Change the previous crontab line to use lockrun</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">*/</span><span style="color: #000000;">5</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>lockrun <span style="color: #660033;">--lockfile</span>=<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>hosting.lockrun <span style="color: #660033;">--</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>my_unison_script.sh</pre></div></div>

<p>All done!!!</p>
<div id="wherego_related"> </div>]]></content:encoded>
			<wfw:commentRss>http://blog.melimato.com/keeping-directories-in-sync-with-unison/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

