<?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>Sean&#039;s Blog &#187; Databases</title>
	<atom:link href="http://seanbehan.com/category/databases/feed/" rel="self" type="application/rss+xml" />
	<link>http://seanbehan.com</link>
	<description>Web Programming, Ruby on Rails, Wordpress, PHP from Burlington, Vermont</description>
	<lastBuildDate>Wed, 18 Jan 2012 21:44:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Backup and Rotate MySQL Databases Simple Bash Script</title>
		<link>http://seanbehan.com/databases/backup-and-rotate-mysql-databases-simple-bash-script/</link>
		<comments>http://seanbehan.com/databases/backup-and-rotate-mysql-databases-simple-bash-script/#comments</comments>
		<pubDate>Sat, 04 Jun 2011 16:29:48 +0000</pubDate>
		<dc:creator>bseanvt</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[backups]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[mysqldump]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=1343</guid>
		<description><![CDATA[Make a directory ( it can anywhere ) called baks/mysql mkdir -p /baks/mysql Create a file (it can be anywhere) called /root/mysql_backups.sh and put this script in it #!/bin/bash # modify the following to suit your environment export DB_BACKUP=&#34;/baks/mysql&#34; export DB_USER=&#34;root&#34; export DB_PASSWD=&#34;your-mysql-password-goes-here&#34; # title and version echo &#34;&#34; echo &#34;Backup and rotate all mysql [...]]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fseanbehan.com%2Fdatabases%2Fbackup-and-rotate-mysql-databases-simple-bash-script%2F&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="Backup and Rotate MySQL Databases Simple Bash Script" data-url="http://seanbehan.com/databases/backup-and-rotate-mysql-databases-simple-bash-script/" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><p>Make a directory ( it can anywhere ) called baks/mysql</p>
<pre class="wp-code-highlight prettyprint">
mkdir -p /baks/mysql
</pre>
<p>Create a file (it can be anywhere) called /root/mysql_backups.sh and put this script in it</p>
<pre class="wp-code-highlight prettyprint">
#!/bin/bash

# modify the following to suit your environment
export DB_BACKUP=&quot;/baks/mysql&quot;
export DB_USER=&quot;root&quot;
export DB_PASSWD=&quot;your-mysql-password-goes-here&quot;

# title and version
echo &quot;&quot;
echo &quot;Backup and rotate all mysql databases&quot;
echo &quot;--------------------------&quot;

rm -rf $DB_BACKUP/04
mv $DB_BACKUP/03 $DB_BACKUP/04
mv $DB_BACKUP/02 $DB_BACKUP/03
mv $DB_BACKUP/01 $DB_BACKUP/02
mkdir $DB_BACKUP/01

echo &quot;* Creating backup...&quot;
mysqldump --user=$DB_USER --password=$DB_PASSWD --all-databases | bzip2 &gt; $DB_BACKUP/01/mysql-`date +%Y-%m-%d`.bz2
echo &quot;----------------------&quot;
echo &quot;Done&quot;
exit 0
</pre>
<p>Install it via cron and have it run at 3:10 am every morning.</p>
<pre class="wp-code-highlight prettyprint">
crontab -e

10 3 * * * /root/mysql_backups.sh  &gt; /baks/status.log
</pre>
<p>This script will save the last 4 days of data.</p>
]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/databases/backup-and-rotate-mysql-databases-simple-bash-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dump MySQL Database without Drop Table Syntax</title>
		<link>http://seanbehan.com/databases/dump-mysql-database-without-drop-table-syntax/</link>
		<comments>http://seanbehan.com/databases/dump-mysql-database-without-drop-table-syntax/#comments</comments>
		<pubDate>Sat, 06 Feb 2010 00:57:34 +0000</pubDate>
		<dc:creator>bseanvt</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[flags]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[mysqldump]]></category>
		<category><![CDATA[syntax]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=781</guid>
		<description><![CDATA[Output .sql file for MySQL but without the drop table syntax before table name use the &#8211;skip-add-drop-table flag mysqldump -u root -p database_name --skip-add-drop-table --skip-lock-tables &#62; database_name.sql]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fseanbehan.com%2Fdatabases%2Fdump-mysql-database-without-drop-table-syntax%2F&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="Dump MySQL Database without Drop Table Syntax" data-url="http://seanbehan.com/databases/dump-mysql-database-without-drop-table-syntax/" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><p>Output .sql file for MySQL but without the drop table syntax before table name use the &#8211;skip-add-drop-table flag</p>
<pre class="wp-code-highlight prettyprint">
mysqldump -u root -p database_name --skip-add-drop-table --skip-lock-tables &gt; database_name.sql
</pre>
]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/databases/dump-mysql-database-without-drop-table-syntax/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Managing Timestamps in MySQL with a Trigger</title>
		<link>http://seanbehan.com/databases/managing-timestamps-in-mysql-with-a-trigger/</link>
		<comments>http://seanbehan.com/databases/managing-timestamps-in-mysql-with-a-trigger/#comments</comments>
		<pubDate>Thu, 10 Dec 2009 17:13:51 +0000</pubDate>
		<dc:creator>bseanvt</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[timestamping]]></category>
		<category><![CDATA[triggers]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=707</guid>
		<description><![CDATA[MySQL doesn&#8217;t support having two columns with time stamping on both initialization and/or on updating at the same time. It would be nice to be able to do *this* where the created_at column gets the current_timestamp on initialization and the updated_at gets changed on updating the row. # like so doesn't work... create table entries( [...]]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fseanbehan.com%2Fdatabases%2Fmanaging-timestamps-in-mysql-with-a-trigger%2F&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="Managing Timestamps in MySQL with a Trigger" data-url="http://seanbehan.com/databases/managing-timestamps-in-mysql-with-a-trigger/" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><p>MySQL doesn&#8217;t support having two columns with time stamping on both initialization and/or on updating at the same time. It would be nice to be able to do *this* where the created_at column gets the current_timestamp on initialization and the updated_at gets changed on updating the row.</p>
<pre class="wp-code-highlight prettyprint">
# like so doesn't work...
create table entries(
  body blob,
  created_at datetime default current_timestamp,
  updated_at timestamp default current_timestamp on update current_timestamp
);
</pre>
<p>Seems like a feature a lot of folks would like. There are two work-arounds. The first is baking it into your application code with something like</p>
<pre class="wp-code-highlight prettyprint">
create table entries(
  body blob,
  created_at datetime default null,
  updated_at timestamp default current_timestamp on update current_timestamp
);
insert into entries (body, created_at) values ('hello world', now());
</pre>
<p>The second way is to create a trigger and call the trigger on your insert action on a row.</p>
<pre class="wp-code-highlight prettyprint">
create table entries (
  body  blob,
  created_at datetime default null,
  updated_at timestamp default null on update current_timestamp
);
create trigger init_created_at before insert on entries for each row set new.created_at = now();
</pre>
<p>Now whenever a new row is created the trigger will be executed and set the time to the current timestamp. You can forget about the created_at column in your code because it&#8217;s not meant to be changed.</p>
]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/databases/managing-timestamps-in-mysql-with-a-trigger/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Install do_mysql Ruby Gem on Mac OS X</title>
		<link>http://seanbehan.com/databases/install-do_mysql-ruby-gem-on-mac-os-x/</link>
		<comments>http://seanbehan.com/databases/install-do_mysql-ruby-gem-on-mac-os-x/#comments</comments>
		<pubDate>Wed, 19 Aug 2009 15:19:05 +0000</pubDate>
		<dc:creator>bseanvt</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[config]]></category>
		<category><![CDATA[datamapper]]></category>
		<category><![CDATA[do_mysql]]></category>
		<category><![CDATA[gems]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Sinatra]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=523</guid>
		<description><![CDATA[I ran into the same problem when installing mysql gem for Rails development. This fix worked for me http://seanbehan.com/programming/fixing-mysql-for-rails-2-2-development-on-mac-os-x/ The same thing works with the data objects gem. Just specify the path the mysql config that it&#8217;s using and the gem should install just fine. gem install do_mysql -- --with-mysql-config=/opt/local/lib/mysql5/bin/mysql_config]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fseanbehan.com%2Fdatabases%2Finstall-do_mysql-ruby-gem-on-mac-os-x%2F&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="Install do_mysql Ruby Gem on Mac OS X" data-url="http://seanbehan.com/databases/install-do_mysql-ruby-gem-on-mac-os-x/" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><p>I ran into the same problem when installing mysql gem for Rails development. This fix worked for me http://seanbehan.com/programming/fixing-mysql-for-rails-2-2-development-on-mac-os-x/</p>
<p>The same thing works with the data objects gem. Just specify the path the mysql config that it&#8217;s using and the gem should install just fine.</p>
<pre class="wp-code-highlight prettyprint">
gem install do_mysql -- --with-mysql-config=/opt/local/lib/mysql5/bin/mysql_config
</pre>
]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/databases/install-do_mysql-ruby-gem-on-mac-os-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Redis Server and Client on Mac OS X and Ubuntu</title>
		<link>http://seanbehan.com/databases/installing-redis-server-and-client-on-mac-os-x-and-ubuntu/</link>
		<comments>http://seanbehan.com/databases/installing-redis-server-and-client-on-mac-os-x-and-ubuntu/#comments</comments>
		<pubDate>Mon, 17 Aug 2009 01:48:55 +0000</pubDate>
		<dc:creator>bseanvt</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[key]]></category>
		<category><![CDATA[redis]]></category>
		<category><![CDATA[store]]></category>
		<category><![CDATA[value]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=519</guid>
		<description><![CDATA[wget http://redis.googlecode.com/files/redis-0.900_2.tar.gz tar xzvf redis-0.900_2.tar.gz cd redis-0.900 make mv redis-server /usr/bin/ mv redis-cli /usr/bin/]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fseanbehan.com%2Fdatabases%2Finstalling-redis-server-and-client-on-mac-os-x-and-ubuntu%2F&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="Installing Redis Server and Client on Mac OS X and Ubuntu" data-url="http://seanbehan.com/databases/installing-redis-server-and-client-on-mac-os-x-and-ubuntu/" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><pre class="wp-code-highlight prettyprint">
wget http://redis.googlecode.com/files/redis-0.900_2.tar.gz
tar xzvf redis-0.900_2.tar.gz
cd redis-0.900
make
mv redis-server /usr/bin/
mv redis-cli /usr/bin/
</pre>
]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/databases/installing-redis-server-and-client-on-mac-os-x-and-ubuntu/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

