<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Lowtown Dogs Home</title>
	<atom:link href="http://lowtowndogshome.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://lowtowndogshome.wordpress.com</link>
	<description>I make all this stuff up you know!</description>
	<lastBuildDate>Fri, 19 Nov 2010 21:15:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='lowtowndogshome.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Lowtown Dogs Home</title>
		<link>http://lowtowndogshome.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://lowtowndogshome.wordpress.com/osd.xml" title="Lowtown Dogs Home" />
	<atom:link rel='hub' href='http://lowtowndogshome.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Setting up Samba</title>
		<link>http://lowtowndogshome.wordpress.com/2010/11/19/setting-up-samba/</link>
		<comments>http://lowtowndogshome.wordpress.com/2010/11/19/setting-up-samba/#comments</comments>
		<pubDate>Fri, 19 Nov 2010 21:15:47 +0000</pubDate>
		<dc:creator>lowtowndogshome</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[samba smb]]></category>

		<guid isPermaLink="false">http://lowtowndogshome.wordpress.com/?p=24</guid>
		<description><![CDATA[To install SAMBA use sudo apt-get install samba, Irrespective of the OS, I always have a dave user. So what I usually do is share out my Linux home directory on the file server so it\’s available to any other machine on the network logged on as me. The file you need to edit is: /etc/samba/smb.conf [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lowtowndogshome.wordpress.com&amp;blog=14415470&amp;post=24&amp;subd=lowtowndogshome&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>To install SAMBA use <strong>sudo apt-get install samba</strong>, Irrespective of the OS, I always have a dave user. So what I usually do is share out my Linux home directory on the file server so it\’s available to any other machine on the network logged on as me.</p>
<p>The file you need to edit is:</p>
<blockquote><p><strong>/etc/samba/smb.conf</strong></p></blockquote>
<p>Look for <strong>[homes]</strong>, you should see something like:</p>
<blockquote><p><strong>;[homes]</strong></p>
<p><strong>;   comment = Home Directories</strong></p>
<p><strong>;   browseable = no</strong></p></blockquote>
<p>The semicolons are commenting out the 3 lines, I replaced the above with:</p>
<blockquote><p><strong>[homes]\r\n</strong></p>
<p><strong>comment = Home Directories</strong></p>
<p><strong>path = %H/files</strong></p>
<p><strong>browseable = no</strong></p>
<p><strong>writeable = yes</strong></p>
<p><strong>create mask = 700</strong></p>
<p><strong>directory mask = 700</strong></p>
<p><strong>invalid users = root bin daemon nobody named sys tty disk mem kmem users</strong></p></blockquote>
<p>Rather than sharing out the /home/dave directory, this shares out a sub directory called files. This is just for tidiness as there are a lot of hidden files in the former that clutter up windows explorer if you have it set to show hidden files.</p>
<p>Use:</p>
<blockquote><p><strong>sudo /etc/init.d/samba restart</strong></p></blockquote>
<p>to restart the samba service with the new settings.</p>
<p>Now I need to create my files directory, this is simply a matter of:</p>
<blockquote><p><strong>cd ~</strong></p>
<p><strong>mkdir files</strong></p></blockquote>
<p>The cd ~ moves me back to my /home/dave directory so I create the files directory in the right place.</p>
<p>Finally:</p>
<blockquote><p><strong>sudo smbpasswd -a dave</strong></p></blockquote>
<p>adds a samba user for dave. Samba has it’s own set of users separate from the OS, this command just creates a new samba user. You will be prompted for a password, I use the same password for samba as I use for logging onto the machine (and my windows box for that matter).</p>
<p>From a windows box, I can now navigate to <strong>\\server IP\dave</strong> where server IP is the IP address of my server.</p>
<p>NOTE: There’s a chance that you might have to restart the samba service last. I forgot to create the files directory and one of my attempts to fix the problem was to restart the server after creating the samba user (it’s done before in the above instructions).</p>
<p>This setup is pretty basic. Things I’d like to do in addition would be:</p>
<ul>
<li>Create a read only share that’s available to      anyone to store media for viewing on any machine on the network,      irrespective of the user logged on. Although selected users should have      permissions to upload,change and delete files.</li>
<li>Create a share that can be updated by anyone.      This would be useful for backing up files from pocket PC devices on the      network that don’t seem to be able to log on as a particular user.</li>
</ul>
<p>I’ve had a brief look at SME server which does all sorts of cool stuff, including being a domain controller for windows boxes. Currently I have to keep my windows, linux and samba passwords in sync, SME server would provide a single central mechanism for keeping everything in line. Hopefully I’ll cover this in a later post.</p>
<h1>Setting up your file server for multiple users – Part 1</h1>
<p>Ok, just a few points to make before we start:</p>
<p>The whole point of this post (and probably the next couple) is to make a useful network file server from an old PC running Ubuntu Linux. The version I’m now running is 7.10 (gutsy  gibbon – I think!).</p>
<ul>
<li>You should have a Linux box already purring      away nicley and you should have installed Samba and optionally SSH (for      remote admin or if you’re running your box headless.</li>
<li>You have an account that can use      &lt;strong&gt;sudo&lt;/strong&gt; to run root (administrative) commands.</li>
<li>I’ll initially jump over the relatively simple      matter of sharing your home folder and look at creating shares that can be      accessed by many users.</li>
<li>I couldn\’t have done this without the help of      the guys at my local Linux User Group who seem to be on hand 24 hours a      day to respond to my daft questions.</li>
</ul>
<p>Ok, here goes:</p>
<p>Log onto your system, either at the console or remotely via SSH (e.g. using puTTY or another fine emulator).</p>
<ul>
<li>Create a suitable named group, for this      example we’ll use “lowtowndogshome”.</li>
</ul>
<blockquote><p><strong>sudo groupadd lowtowndogshome</strong></p></blockquote>
<ul>
<li>Create the required directory tree, again for      this example, I’m going to create a directory called “shared” in the root      of the filesystem.</li>
</ul>
<blockquote><p><strong>sudo mkdir /shared</strong></p></blockquote>
<ul>
<li>Change group ownership of the directory (or      directories) you just created to the group you created earlier, note that      the owner is still root, this seems to be ok.</li>
</ul>
<blockquote><p><strong>sudo chgrp lowtowndogshome /shared</strong></p></blockquote>
<ul>
<li>Change permissions so that the owner and group      members have full access to the directory.</li>
</ul>
<blockquote><p><strong>sudo chmod 770 /shared</strong></p></blockquote>
<p>Each Linux user that needs access to the new directory should be assigned to the new group, make sure that you use the <strong>-a</strong> option on the command below otherwise bad things can happen! I’m using a local account called dave. See below for the command line required to create a new user.</p>
<blockquote><p><strong>sudo usermod -a -G lowtowndogshome dave</strong></p></blockquote>
<p>If you’re logged on as the user you’ve just given group membership to, you’ll need to log off and back on again for the change to take effect.</p>
<p>Now when you’re logged on as the user(s) who are now in the new group you should be able to navigate to the new directory and create, modify and delete files.</p>
<blockquote><p><strong>cd /shared</strong></p>
<p><strong>touch fred.txt</strong></p>
<p><strong>rm fred.txt</strong></p></blockquote>
<p>None of the above commands should result in an error.</p>
<p>To create a new user use:</p>
<blockquote><p><strong>sudo useradd -m fred</strong></p></blockquote>
<p>fred is the name of the new user, the <strong>-m</strong> option makes Linux create a home directory for the user (e.g. /home/fred), this is useful if you also want to share the users home directory (see a subsequent post, coming soon).</p>
<h1>Setting up your file server for multiple users – Part 2</h1>
<p>Assuming you’ve done everything in the previous post, all you need to do now is set up your samba service:</p>
<ul>
<li>Backup your existing configuration.</li>
</ul>
<blockquote><p><strong>sudo cp /etc/samba/smb.conf smb.conf.original</strong></p></blockquote>
<ul>
<li>Edit your smb.conf file, add something      resembling the following on the line above the [homes] section.</li>
</ul>
<blockquote><p><strong>[share]</strong></p>
<p><strong>comment       = Shared files</strong></p>
<p><strong>browseable    = yes</strong></p>
<p><strong>read only     = no</strong></p>
<p><strong>writeable = yes</strong></p>
<p><strong>guest ok      = no</strong></p>
<p><strong>path          = /shared</strong></p>
<p><strong>invalid users = root bin daemon named sys tty disk mem kmem users</strong></p></blockquote>
<ul>
<li>Create a samba account for each Linux user      that will want to see this directory from a windows (or other Linux)      machine. You will be prompted for a password, for my dave user, I use the      same password that I use on my windows box but this doesn’t have to be the      case I suppose.</li>
</ul>
<blockquote><p><strong>smbpasswd -a dave</strong></p></blockquote>
<ul>
<li>You may have to restart the samba service for      changes to take effect, this is always a good idea if you\’re having      problems.</li>
</ul>
<blockquote><p><strong>sudo /etc/init.d/samba restart</strong></p></blockquote>
<p>Now from a windows machine, logged on as a user with the same username (and password in my case) I can navigate to <strong>\server_address\share</strong> and drop files ’till my hearts content.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lowtowndogshome.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lowtowndogshome.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/lowtowndogshome.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/lowtowndogshome.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/lowtowndogshome.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/lowtowndogshome.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/lowtowndogshome.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/lowtowndogshome.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/lowtowndogshome.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/lowtowndogshome.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/lowtowndogshome.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/lowtowndogshome.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/lowtowndogshome.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/lowtowndogshome.wordpress.com/24/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lowtowndogshome.wordpress.com&amp;blog=14415470&amp;post=24&amp;subd=lowtowndogshome&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lowtowndogshome.wordpress.com/2010/11/19/setting-up-samba/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6a446171e2dd9c651769a26f31817159?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">lowtowndogshome</media:title>
		</media:content>
	</item>
		<item>
		<title>Backup and Restore of MySQL</title>
		<link>http://lowtowndogshome.wordpress.com/2010/11/19/backup-and-restore-of-mysql/</link>
		<comments>http://lowtowndogshome.wordpress.com/2010/11/19/backup-and-restore-of-mysql/#comments</comments>
		<pubDate>Fri, 19 Nov 2010 20:50:10 +0000</pubDate>
		<dc:creator>lowtowndogshome</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://lowtowndogshome.wordpress.com/?p=18</guid>
		<description><![CDATA[Thought this might be tricky but it’s reasonably easy; to backup, it’s just one command: mysqldump -u &#60;user&#62; -p&#60;password&#62; &#60;database&#62; &#62; ~/dumpfile.sql replace &#60;user&#62; with an appropriately authorised user. replace &#60;password&#62; with their password (note there’s no space after the “-p”). replace &#60;database&#62; with the name of the database you want to export. Once completed, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lowtowndogshome.wordpress.com&amp;blog=14415470&amp;post=18&amp;subd=lowtowndogshome&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Thought this might be tricky but it’s reasonably easy; to backup, it’s just one command:</p>
<blockquote><p><strong>mysqldump -u &lt;user&gt; -p&lt;password&gt; &lt;database&gt; &gt; ~/dumpfile.sql</strong></p></blockquote>
<p>replace &lt;user&gt; with an appropriately authorised user.<br />
replace &lt;password&gt; with their password (note there’s no space after the “-p”).<br />
replace &lt;database&gt; with the name of the database you want to export.</p>
<p>Once completed, dumpfile.sql contains all the SQL required to rebuild the objects within the database, it’s not a wierd binary format.</p>
<p>To restore, again, it’s a single command:</p>
<blockquote><p><strong> mysql -u &lt;user&gt; -p&lt;password&gt; &lt;database&gt; &lt; dumpfile.sql</strong></p></blockquote>
<p>The same substitution rules apply as before. I guess the database may need to exist beforehand.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lowtowndogshome.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lowtowndogshome.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/lowtowndogshome.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/lowtowndogshome.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/lowtowndogshome.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/lowtowndogshome.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/lowtowndogshome.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/lowtowndogshome.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/lowtowndogshome.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/lowtowndogshome.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/lowtowndogshome.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/lowtowndogshome.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/lowtowndogshome.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/lowtowndogshome.wordpress.com/18/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lowtowndogshome.wordpress.com&amp;blog=14415470&amp;post=18&amp;subd=lowtowndogshome&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lowtowndogshome.wordpress.com/2010/11/19/backup-and-restore-of-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6a446171e2dd9c651769a26f31817159?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">lowtowndogshome</media:title>
		</media:content>
	</item>
		<item>
		<title>MYSQL – Getting Started</title>
		<link>http://lowtowndogshome.wordpress.com/2010/07/01/mysql-%e2%80%93-getting-started/</link>
		<comments>http://lowtowndogshome.wordpress.com/2010/07/01/mysql-%e2%80%93-getting-started/#comments</comments>
		<pubDate>Thu, 01 Jul 2010 20:47:50 +0000</pubDate>
		<dc:creator>lowtowndogshome</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[autonumber]]></category>
		<category><![CDATA[constraints]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[ri]]></category>
		<category><![CDATA[table]]></category>

		<guid isPermaLink="false">http://lowtowndogshome.wordpress.com/?p=11</guid>
		<description><![CDATA[Right, Enough faffing about! This post will just cover a few key points in getting going with MySQL. I’m going to approach it from the point of view of an oracle developer so some of the terminology might not be spot on. Basics First thing’s first, you need to change the root password for your [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lowtowndogshome.wordpress.com&amp;blog=14415470&amp;post=11&amp;subd=lowtowndogshome&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Right,</p>
<p>Enough faffing about! This post will just cover a few key points in getting going with MySQL. I’m going to approach it from the point of view of an oracle developer so some of the terminology might not be spot on.</p>
<h1>Basics</h1>
<p>First thing’s first, you need to change the root password for your MySQL server. This is pretty simple and can be found easily via googling. For convenience, I’ve replicated this below:</p>
<p>For a fresh install use:</p>
<pre>mysqladmin -u root password &lt;NEWPASSWORD&gt;</pre>
<p>There are ways of doing this by directly updating system tables but that just sounds a bit dodgy to me with my oracle background.</p>
<p>Once you’ve done this, you should be able to log onto the database server using:</p>
<pre>mysql –u root -p</pre>
<p>then entering the password selected in the previous step.</p>
<p>At this point you can try:</p>
<pre>show databases ;</pre>
<p>to see a list of databases on your server (remember the semicolon), the output might look something like this:</p>
<pre>+--------------------+</pre>
<pre>| Database           |</pre>
<pre>+--------------------+</pre>
<pre>| information_schema |</pre>
<pre>| mysql              |</pre>
<pre>+--------------------+</pre>
<pre>2 rows in set (0.00 sec)</pre>
<h1>Create a database</h1>
<p>We’ll create a new database next, this is as simple as:</p>
<pre>create database mydb ;</pre>
<p>I dunno about you but I also like to create a user, instead of using the root account, to do my development. It helps identify problems with permissions at an early stage.</p>
<p>I’ve tried a few ways to do this and this one seems to work the best for me:</p>
<pre>grant create, select, insert, update, delete, alter, lock tables on mydb.* to ‘myuser’@localhost identified by ‘Pa55word’ ;</pre>
<p>If you now quit out of the MySQL command prompt (use \q) you should be able to log in with the new user details, e.g.:</p>
<pre>mysql -u myuser -p</pre>
<p>and enter the new password when prompted. Now enter:</p>
<pre>use mydb</pre>
<p>to start working with the new database, not sure if this is mandatory or whether it justs saves on a bit of subsequent typing.</p>
<h1>Create some tables</h1>
<p>A quick scan of the <a href="http://dev.mysql.com/doc/refman/5.1/en/create-table.html">official documentation</a> shows many options for table creation. I’m going to stick with a good old fashioned create statement that specifies the column names and types and I’ll also cover referential integrity (primary and foreign keys) and constraints (unique keys, permitted values). Ok, let’s create a couple of tables, we’ll leave out RI stuff for now.</p>
<pre>create table cust ( id int, name varchar(50));</pre>
<pre>create table job (id int, notes varchar(200), cust_id int);</pre>
<p>Ok, now add primary keys; these will be the id columns on both tables.</p>
<pre>alter table cust add primary key(id) ;</pre>
<pre>alter table job add primary key(id) ;</pre>
<p>If you use:</p>
<pre>desc cust ;</pre>
<p>..or</p>
<pre>desc job ;</pre>
<p>you’ll see that the key column has been populated with PRI for both id fields on both tables. Now to link the two tables together:</p>
<pre>alter table job add constraint foreign key (cust_id) references cust (id) ;</pre>
<p>..seems to work! The Key column when describing the job table contains “MUL” which seems to indicate that the column can contain multiple identical values (seems fair enough!).</p>
<p>Finally, let’s try and automatically generate the id column values. In oracle we’d use sequences and triggers but the solution here is more like Microsoft Access autonumbers:</p>
<pre>alter table cust modify id int auto_increment ;</pre>
<pre>alter table job modify id int auto_increment ;</pre>
<p>At some point it might be worth looking at using GUIDs instead of a linear sequence as this spreads the rows more evenly across the database and can have some benefits where rows are created by disconnected processes and then synced back to the main database (GUIDs are unique so you’ll never generate duplicates!!).</p>
<p>Let’s give it a quick check:</p>
<pre>insert into cust (name) values (’Dave’) ;</pre>
<pre>insert into cust (name) values (’Tom’) ;</pre>
<pre>insert into cust (name) values (’Dick’) ;</pre>
<pre>insert into cust (name) values (’Harry’) ;</pre>
<pre>select * from cust ;</pre>
<p>gives:</p>
<pre>+----+-------+</pre>
<pre>| id | name  |</pre>
<pre>+----+-------+</pre>
<pre>|  1 | Dave  |</pre>
<pre>|  2 | Tom   |</pre>
<pre>|  3 | Dick  |</pre>
<pre>|  4 | Harry |</pre>
<pre>+----+-------+</pre>
<pre>4 rows in set (0.00 sec)</pre>
<p>Incidentally, the inserts seem to have been commited as a rollback statement had no effect on the contents of the table after the inserts. I’ll need to look more at building transactions later on.</p>
<p>Let’s now check the referential integrity works:</p>
<pre>insert into job (notes, cust_id) values (’Boiler Repair’,1) ;</pre>
<pre>insert into job (notes, cust_id) values (’Boiler Repair’,5) ;</pre>
<p>Curiously, both statements work which is a shame as there’s no cust record with an id of 5!, back to the drawing board!!</p>
<h1>Revised create tables</h1>
<p>Right, the key to fix this problem appears to be to use the Engine=InnoDB clause when creating tables.  I’ve dropped the tables and created a script to recreate them:</p>
<pre>use mydb ;</pre>
<pre>create table cust (</pre>
<pre>id int auto_increment ,</pre>
<pre>name varchar(50),</pre>
<pre>primary key(id))</pre>
<pre>engine=innodb ;</pre>
<pre>create table job (</pre>
<pre>id int auto_increment,</pre>
<pre>notes varchar(200),</pre>
<pre>cust_id int,</pre>
<pre>primary key(id),</pre>
<pre>foreign key(cust_id) references cust(id))</pre>
<pre>engine=innodb ;</pre>
<p>Now if I try to create a row on the job table that references a non existent customer, I get an error:</p>
<pre>mysql&gt; insert into job (notes, cust_id) values ('Fix Boiler',5) ;</pre>
<pre>ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails (`mydb/job`, CONSTRAINT `job_ibfk_1` FOREIGN KEY (`cust_id`) REFERENCES `cust` (`id`))</pre>
<p>You can specify behavours to follow when a parent row is deleted (e.g. cascade) but I’ve not bothered at this stage.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lowtowndogshome.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lowtowndogshome.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/lowtowndogshome.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/lowtowndogshome.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/lowtowndogshome.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/lowtowndogshome.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/lowtowndogshome.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/lowtowndogshome.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/lowtowndogshome.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/lowtowndogshome.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/lowtowndogshome.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/lowtowndogshome.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/lowtowndogshome.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/lowtowndogshome.wordpress.com/11/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lowtowndogshome.wordpress.com&amp;blog=14415470&amp;post=11&amp;subd=lowtowndogshome&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lowtowndogshome.wordpress.com/2010/07/01/mysql-%e2%80%93-getting-started/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6a446171e2dd9c651769a26f31817159?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">lowtowndogshome</media:title>
		</media:content>
	</item>
		<item>
		<title>Scripting in the MySQL Command line environment</title>
		<link>http://lowtowndogshome.wordpress.com/2010/07/01/scripting-in-the-mysql-command-line-environment/</link>
		<comments>http://lowtowndogshome.wordpress.com/2010/07/01/scripting-in-the-mysql-command-line-environment/#comments</comments>
		<pubDate>Thu, 01 Jul 2010 20:40:14 +0000</pubDate>
		<dc:creator>lowtowndogshome</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://lowtowndogshome.wordpress.com/?p=8</guid>
		<description><![CDATA[In Oracle, I’m used to the ed command to create scripts and the @ operator to run them. You can work in a similar way with MySQL: To create a script from within the MySQL environment use: \! vi test.sql .. there’s a space after the exclamation mark and this assumes that you like the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lowtowndogshome.wordpress.com&amp;blog=14415470&amp;post=8&amp;subd=lowtowndogshome&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In Oracle, I’m used to the ed command to create scripts and the @ operator to run them. You can work in a similar way with MySQL:</p>
<p>To create a script from within the MySQL environment use:</p>
<blockquote>
<pre>\! vi test.sql</pre>
</blockquote>
<p>.. there’s a space after the exclamation mark and this assumes that you like the vi editor. Essentially it opens up vi so you can create the test.sql file. If you store all of your scripts in a particular directory (e.g. /home/dave/sql) then it may help if you start mysql in that location.</p>
<p>\! Essentially lets you enter shell commands so if you use HOST from within oracle SQL Plus, you can get the same effect in MySQL by keying:</p>
<blockquote>
<pre>\! sh</pre>
</blockquote>
<p>Once you’ve keyed in your script, you can run it using the following syntax:</p>
<blockquote>
<pre>\. test.sql</pre>
</blockquote>
<p>..again, there’s a space after the full stop and you need to remember the .sql suffix when running and editing the script.</p>
<p>The script can contain multiple statements, for example the following works fine as the contents of the test.sql file.</p>
<blockquote>
<pre>use mydb ;</pre>
<pre>select * from cust ;</pre>
</blockquote>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lowtowndogshome.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lowtowndogshome.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/lowtowndogshome.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/lowtowndogshome.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/lowtowndogshome.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/lowtowndogshome.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/lowtowndogshome.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/lowtowndogshome.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/lowtowndogshome.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/lowtowndogshome.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/lowtowndogshome.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/lowtowndogshome.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/lowtowndogshome.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/lowtowndogshome.wordpress.com/8/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lowtowndogshome.wordpress.com&amp;blog=14415470&amp;post=8&amp;subd=lowtowndogshome&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lowtowndogshome.wordpress.com/2010/07/01/scripting-in-the-mysql-command-line-environment/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6a446171e2dd9c651769a26f31817159?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">lowtowndogshome</media:title>
		</media:content>
	</item>
		<item>
		<title>Up And Running!</title>
		<link>http://lowtowndogshome.wordpress.com/2010/06/27/hello-world/</link>
		<comments>http://lowtowndogshome.wordpress.com/2010/06/27/hello-world/#comments</comments>
		<pubDate>Sun, 27 Jun 2010 23:17:34 +0000</pubDate>
		<dc:creator>lowtowndogshome</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://lowtowndogshome.wordpress.com/?p=1</guid>
		<description><![CDATA[I don&#8217;t for a second think that anyone was subscribing to this and for that matter I&#8217;m not that bothered! This is just for my personal use as I try to bluff my way in IT until I retire! For anyone who is reading this, the story so far is; I originally self-hosted WordPress on my [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lowtowndogshome.wordpress.com&amp;blog=14415470&amp;post=1&amp;subd=lowtowndogshome&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I don&#8217;t for a second think that anyone was subscribing to this and for that matter I&#8217;m not that bothered! This is just for my personal use as I try to bluff my way in IT until I retire!</p>
<p>For anyone who is reading this, the story so far is; I originally self-hosted WordPress on my ISPs CGI server but it got hacked, so I trashed it. My ISP upgraded their security policies and I couldn&#8217;t get WordPress to work again!</p>
<p>Now I&#8217;m hosting it on WordPress.Com so hopefully I won&#8217;t have to bother about upgrades or hackers ever again!</p>
<p>Watch this space as I&#8217;ll be uploading content very soon.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lowtowndogshome.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lowtowndogshome.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/lowtowndogshome.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/lowtowndogshome.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/lowtowndogshome.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/lowtowndogshome.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/lowtowndogshome.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/lowtowndogshome.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/lowtowndogshome.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/lowtowndogshome.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/lowtowndogshome.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/lowtowndogshome.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/lowtowndogshome.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/lowtowndogshome.wordpress.com/1/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lowtowndogshome.wordpress.com&amp;blog=14415470&amp;post=1&amp;subd=lowtowndogshome&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lowtowndogshome.wordpress.com/2010/06/27/hello-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6a446171e2dd9c651769a26f31817159?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">lowtowndogshome</media:title>
		</media:content>
	</item>
	</channel>
</rss>
