<?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>evardsson.com: stuff that w0rks &#187; MySQL</title>
	<atom:link href="http://www.evardsson.com/blog/tag/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.evardsson.com/blog</link>
	<description>tweaks and hacks, php, python, music, home and ???</description>
	<lastBuildDate>Mon, 23 Jan 2012 18:38:48 +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>Massive Fail!</title>
		<link>http://www.evardsson.com/blog/2009/08/17/massive-fail/</link>
		<comments>http://www.evardsson.com/blog/2009/08/17/massive-fail/#comments</comments>
		<pubDate>Mon, 17 Aug 2009 23:42:56 +0000</pubDate>
		<dc:creator>Sjan Evardsson</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Fail]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.evardsson.com/blog/?p=371</guid>
		<description><![CDATA[While looking for the source of database backup errors I found it, the hard way. I have been running my database on a separate hard disk from everything else, and have been getting occassional errors from the cron script that does a nightly dump. I was under the impression that this was due to latency [...]]]></description>
			<content:encoded><![CDATA[<p>While looking for the source of database backup errors I found it, the hard way. I have been running my database on a separate hard disk from everything else, and have been getting occassional errors from the cron script that does a nightly dump. I was under the impression that this was due to latency causing the script to time out. Not the case.</p>
<p>Looking at the dump it seemed like everything was being written ok, at least it looked that way yesterday. (I have not had much time for site maintenance, so this has been in the &#8220;put it off until later&#8221; pile.) While looking at the script this afternoon, and trying another run it timed out again (or so I thought). I figured I could put it off until this weekend, until I went to look at the site and got the big &#8220;Unable to contact the database&#8221; error. I went the server and fired up mysql on the command line and discovered that there were NO DATABASES! I tried to get a file listing of the /var/lib/mysql directory and got nothing. Nada. Since I don&#8217;t seem to be able to get anything off of that disc I did a quick modification of the fstab (to remove the line mounting that drive), rebuilt the dbs from the last (failed) backup, and here I am, missing two months worth of data.</p>
<p>Can I cry now?</p>
<p>In case you are wondering, the <a href="http://www.evardsson.com/margins.php">Margin vs Markup</a> page is still available (as I made it a regular page as well as a post, it was my most popular ever).</p>
<p>EDIT: Ah the joys of using decade-old equipment.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.evardsson.com/blog/2009/08/17/massive-fail/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New Project: SPDO</title>
		<link>http://www.evardsson.com/blog/2009/01/28/new-project-spdo/</link>
		<comments>http://www.evardsson.com/blog/2009/01/28/new-project-spdo/#comments</comments>
		<pubDate>Thu, 29 Jan 2009 02:00:40 +0000</pubDate>
		<dc:creator>Sjan Evardsson</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PostgresQL]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[SPDO]]></category>
		<category><![CDATA[sqlite]]></category>

		<guid isPermaLink="false">http://www.evardsson.com/blog/?p=284</guid>
		<description><![CDATA[I have just posted the (embarrassingly empty) page for my new pet project: SPDO (Sjan&#8217;s PDO) &#8211; in two flavors: PHP and Python. There are only about a thousand PDOs out there, and perhaps a dozen or so of them are really functional and (in a few cases) very polished pieces of work. So why [...]]]></description>
			<content:encoded><![CDATA[<p>I have just posted the (embarrassingly empty) page for my new pet project: SPDO (Sjan&#8217;s PDO) &#8211; in two flavors: <a href="http://www.php.net">PHP</a> and <a href="http://python.org/">Python</a>.</p>
<p>There are only about a thousand PDOs out there, and perhaps a dozen or so of them are really functional and (in a few cases) very polished pieces of work. So why am I messing with writing my own? A couple of reasons:</p>
<ol>
<li>I like to have coding signatures that are consistent, whether I am working with <a href="http://www.postgresql.org/">PostgreSQL</a>, <a href="http://www.mysql.com/">MySQL</a> or (heaven help us all) <a href="http://www.sqlite.org/">SQLite</a>.</li>
<li>I like to have coding signatures that are (reasonably) consistent across different languages &#8211; in this case Python and PHP.</li>
<li>I wanted to take advantage of Prepared Statements where I could, even though the PHP implementations of those are pretty weak (especially in the case of MySQL).</li>
</ol>
<p>Currently implemented in</p>
<ul>
<li>Python:
<ul>
<li>PostgreSQL (with prepared statements)</li>
<li>SQLite (no prepared statements).</li>
</ul>
</li>
<li>PHP
<ul>
<li>PostgreSQL (with prepared statements)</li>
<li>MySQL (with prepared statements)</li>
<li>SQLite (no prepared statements)</li>
</ul>
</li>
</ul>
<p>Here&#8217;s an example of how they work (in most simplistic terms):</p>
<pre class="brush: python">
#in Python
from pyDB import *
db = pyDB('mysite')
newid = db.insert('INSERT INTO test (name, value) VALUES (?,?)',['foo','bar'])
update_count = db.update('UPDATE test SET value=? WHERE id=?',['baz',newid])
results = db.select('SELECT * FROM test')
for row in results:
    for i in row:
        print "\t", i,"\t", row[i]
delete_count = db.delete('DELETE FROM test WHERE id=?',[newid])
</pre>
<pre class="brush: php">
//in PHP
require_once('phpdb.php');
$db = new phpDB('test');
$newid = $db->insert('INSERT INTO test (name, value) VALUES (?,?)',array('foo','bar'));
$update_count = $db->update('UPDATE test SET value=? WHERE id=?',array('baz',newid));
$results = db->select('SELECT * FROM test');
foreach($results as $row)
{
    foreach ($row as $key=>$val)
    {
        print "\t$key\t$val";
    }
}
$delete_count = $db->delete('DELETE FROM test WHERE id=?',array($newid));
</pre>
<p>The page with links to the code is in the list up top, and everything is MIT license. Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.evardsson.com/blog/2009/01/28/new-project-spdo/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Drizzle &#8211; Lightweight DB Based on MySQL</title>
		<link>http://www.evardsson.com/blog/2008/07/23/drizzle-lightweight-db-based-on-mysql/</link>
		<comments>http://www.evardsson.com/blog/2008/07/23/drizzle-lightweight-db-based-on-mysql/#comments</comments>
		<pubDate>Thu, 24 Jul 2008 00:12:57 +0000</pubDate>
		<dc:creator>Sjan Evardsson</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Drizzle]]></category>

		<guid isPermaLink="false">http://www.evardsson.com/blog/?p=237</guid>
		<description><![CDATA[Brain Acker, director of architecture for MySQL has opened the door to Drizzle, a light-weight, high-concurrency database server based on MySQL, targeted at web applications. The architectural ideas as described in the FAQ: A micro-kernel that we then extend to add what we need (all additions come through interfaces that can be compiled/loaded in as [...]]]></description>
			<content:encoded><![CDATA[<p>Brain Acker, director of architecture for <a href="http://www.mysql.com">MySQL</a> has opened the door to <a href="https://launchpad.net/drizzle">Drizzle</a>, a light-weight, high-concurrency database server based on MySQL, targeted at web applications.</p>
<p>The architectural ideas as described in the <a href="http://bazaar.launchpad.net/~drizzle-developers/drizzle/development/annotate/205?file_id=drizzle.faq-20080625052902-61bbthtf22shh0p6-4">FAQ</a>:</p>
<blockquote><p>A micro-kernel that we then extend to add what we need (all additions come through interfaces that can be compiled/loaded in as needed). The target for the project is web infrastructure backend and cloud components.</p></blockquote>
<p>The FAQ goes on explain the differences between Drizzle and MySQL which include:</p>
<blockquote><p>No modes, views, triggers, prepared statements, stored procedures, query cache, data conversion inserts, ACL. Fewer data types.  Less engines, less code. Assume the primary engine is transactional.</p></blockquote>
<p>Michael Widenius, founder and original MySQL developer, explains more about Drizzle in <a href="http://monty-says.blogspot.com/2008/07/what-if.html">this blog post</a>, including the most interesting piece (to me) &#8211; that Drizzle will always contain the most up-to-date InnoDB code, meaning you don&#8217;t need to wait around for MySQL 6 or download the plugins from Oracle each year to get the latest and greatest.</p>
<p>While Drizzle is still in development you can check out the code and try it out. Or maybe even get involved and help out. More information on how to do both is available on the <a href="http://drizzle.wikia.com/wiki/Drizzle_Wiki">wiki</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.evardsson.com/blog/2008/07/23/drizzle-lightweight-db-based-on-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache 2.2.6, PHP 5.2.4 and MySQL 5.0.45 on OS X</title>
		<link>http://www.evardsson.com/blog/2007/09/17/apache-226-php-524-and-mysql-5045-on-os-x/</link>
		<comments>http://www.evardsson.com/blog/2007/09/17/apache-226-php-524-and-mysql-5045-on-os-x/#comments</comments>
		<pubDate>Tue, 18 Sep 2007 02:53:32 +0000</pubDate>
		<dc:creator>Sjan Evardsson</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[OSĀ X]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.evardsson.com/blog/2007/09/17/apache-226-php-524-and-mysql-5045-on-os-x/</guid>
		<description><![CDATA[I got tired of looking for a way to replace the Apache/PHP that Apple packages with OS X (without breaking anything else in the process) so I decided to install Apache 2.2 and PHP5 in their own location to avoid stepping on the Apple package toes. Since I do a great deal of development again [...]]]></description>
			<content:encoded><![CDATA[<p>I got tired of looking for a way to replace the Apache/PHP that Apple packages with OS X (without breaking anything else in the process) so I decided to install Apache 2.2 and PHP5 in their own location to avoid stepping on the Apple package toes.</p>
<p>Since I do a great deal of development again MySQL I needed to install that as well, and figured that I would probably need the GD functionality as well so I grabbed libjpeg and libpng to make those work as well. This is the step-by-step.</p>
<p>(Props to James Pelow and his <a href="http://www.phpmac.com/articles.php?view=252">article from last year</a>, from which I borrowed the configure command lines and configuration modifications, as well as the idea of installing the whole mess in /apache2.)</p>
<p>Download the latest MySQL (I used the package version) from <a href="http://dev.mysql.com/downloads/">MySQL</a>.</p>
<p>Installation is straightforward following the same methods as any other Mac installer.</p>
<p>Download and install libjpeg and libpng &#8211; from <a href="http://ethan.tira-thompson.com/Mac%20OS%20X%20Ports.html">Ethan Tira-Thompson</a> (this is also in a Mac installer which contains both libraries in one installer).</p>
<p>Download the latest Apache httpd server (Unix source) from <a href="http://httpd.apache.org/download.cgi">Apache</a></p>
<p>in the terminal:</p>
<pre>
tar -xzvf httpd-2.2.6.tar.gz &amp;&amp; cd httpd-2.2.6

./configure

--prefix=/apache2

--enable-module=most

--enable-shared=max

make

sudo make install

sudo mkdir /apache2/php</pre>
<p>Download the latest PHP from <a href="http://www.php.net/downloads.php">PHP</a></p>
<pre>
tar -xzvf php-5.2.4.tar.gz &amp;&amp; cd php-5.2.4

./configure

--prefix=/apache2/php

--with-zlib

--with-xml

--with-ldap=/usr

--enable-cli

--with-zlib-dir=/usr

--enable-exif

--enable-ftp

--enable-mbstring

--enable-mbregex

--enable-dbx

--enable-sockets

--with-iodbc=/usr

--with-curl=/usr

--with-mysql=/usr/local/mysql

--with-gd

--with-jpeg-dir=/usr/local

--with-png-dir=/usr/local</pre>
<pre>--with-apxs2=/apache2/bin/apxsmake

sudo make install

sudo cp php.ini-dist /apache2/php/lib/php.ini</pre>
<p>Now to make your Apache2.2 a little more &#8216;Mac&#8217; &#8211; you can point it at the Mac web shared files folder, change the user and group and change the location for user files to match the Mac folder system.</p>
<p>Edit httpd.conf (I use nano, you can use any flat text editor like nano, pico, vi, emacs or even BBedit)</p>
<pre>sudo nano -w /apache2/conf/httpd.conf</pre>
<p>The changes to httpd.conf I made:<br />
I changed</p>
<pre>User daemon</pre>
<pre>Group daemon</pre>
<p>to</p>
<pre>User www</pre>
<pre>Group www</pre>
<p>and</p>
<pre>DocumentRoot "/apache2/htdocs"</pre>
<p>to</p>
<pre>DocumentRoot "/Library/WebServer/Documents"</pre>
<p>and</p>
<pre>&lt;Directory "/apache2/htdocs"&gt;</pre>
<p>to</p>
<pre>&lt;Directory "/Library/WebServer/Documents"&gt;</pre>
<p>and added</p>
<pre>AddType application/x-httpd-php .php</pre>
<pre>AddType application/x-httpd-php-source .phps

DirectoryIndex index.html index.php</pre>
<p>Edit httpd-userdir.conf</p>
<pre>sudo nano -w /apache2/conf/extra/httpd-userdir.conf</pre>
<p>The changes to httpd-userdir.conf I made:<br />
I changed</p>
<pre>UserDir public_html</pre>
<p>to</p>
<pre>UserDir Sites</pre>
<p>To start and stop the server:<br />
MySQL comes with a Preference Pane that allows you to start and stop it there. To start and stop Apache you need to first make sure that the default Apache shipped with OS X is stopped.</p>
<pre>sudo /apache2/bin/apachectl start</pre>
<pre>sudo /apache2/bin/apachectl stop</pre>
<p>I only ran into one issue, when trying to start the server I ran against the following error message (and no running server, of course):</p>
<pre>httpd: Syntax error on line 53 of /apache2/conf/httpd.conf:</pre>
<pre>Cannot load /apache2/modules/libphp5.so into server:</pre>
<pre>Library not loaded: /usr/local/mysql/lib/mysql/libmysqlclient.15.dylib</pre>
<pre>Referenced from: /apache2/modules/libphp5.son  Reason: image not found</pre>
<p>To fix this I did the following:</p>
<pre>cd /usr/local/mysql/lib</pre>
<pre>sudo mkdir /usr/local/mysql/lib/mysql

for i in `ls ./l*`; do sudo ln -sf /usr/local/mysql/lib/$i /usr/local/mysql/lib/mysql/$i; done</pre>
<p>This creates soft links in the directory that libphp5.so is looking for the MySQL libraries.</p>
<p>Then it started right up! Wheee! (I did a quick test by dropping PhpMyAdmin into the /Library/WebServer/Documents folder and browsed to it &#8211; the whole Apache/PHP/MySQL is working correctly)</p>
<p>Technorati Tags: <a href="http://technorati.com/tag/Apache%202.2" class="performancingtags" rel="tag">Apache 2.2</a>, <a href="http://technorati.com/tag/PHP5" class="performancingtags" rel="tag">PHP5</a>, <a href="http://technorati.com/tag/MySQL%205" class="performancingtags" rel="tag">MySQL 5</a>, <a href="http://technorati.com/tag/OS%20X" class="performancingtags" rel="tag">OS X</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.evardsson.com/blog/2007/09/17/apache-226-php-524-and-mysql-5045-on-os-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A simple intro to database normalization</title>
		<link>http://www.evardsson.com/blog/2006/08/30/a-simple-intro-to-database-normalization/</link>
		<comments>http://www.evardsson.com/blog/2006/08/30/a-simple-intro-to-database-normalization/#comments</comments>
		<pubDate>Wed, 30 Aug 2006 22:45:00 +0000</pubDate>
		<dc:creator>Sjan Evardsson</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://localhost/wordpress/?p=25</guid>
		<description><![CDATA[I found a very clear, well-written introductory example to database normalization on devshed. Although it is in the MySQL portion of the site, it applies equally well across the board to other RDBMSs. To get more details on normalization, the normal forms, and general good database development in general, check out Database Design for Mere [...]]]></description>
			<content:encoded><![CDATA[<p>I found a very clear, well-written introductory <a href="http://www.devshed.com/c/a/MySQL/An-Introduction-to-Database-Normalization/">example</a> to database normalization on devshed. Although it is in the MySQL portion of the site, it applies equally well across the board to other RDBMSs.</p>
<p>To get more details on normalization, the normal forms, and general good database development in general, check out <a href="http://www.amazon.com/Database-Design-Mere/dp/0201752840/sr=8-1/qid=1156966801/ref=pd_bbs_1/002-0285788-0488009?ie=UTF8">Database Design for Mere Mortals: A Hands-On Guide to Relational Database Design, Second Edition</a> by Michael J. Hernandez. Without a doubt the most useful db development book I&#8217;ve ever laid my hands on.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.evardsson.com/blog/2006/08/30/a-simple-intro-to-database-normalization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

