<?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>Christian Riesen &#187; Backup</title>
	<atom:link href="http://christianriesen.com/tag/backup/feed/" rel="self" type="application/rss+xml" />
	<link>http://christianriesen.com</link>
	<description>Life and work in the information and communication age</description>
	<lastBuildDate>Mon, 12 Jul 2010 10:39:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Creating a MySQL dump in CSV format</title>
		<link>http://christianriesen.com/2009/06/creating-a-mysql-dump-in-csv-format/</link>
		<comments>http://christianriesen.com/2009/06/creating-a-mysql-dump-in-csv-format/#comments</comments>
		<pubDate>Fri, 26 Jun 2009 07:33:47 +0000</pubDate>
		<dc:creator>Christian Riesen</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Backup]]></category>
		<category><![CDATA[mysqldump]]></category>

		<guid isPermaLink="false">http://christianriesen.com/?p=39</guid>
		<description><![CDATA[Mostly, a dump of a db is wanted in SQL. In case of eme [...]]]></description>
			<content:encoded><![CDATA[<p>Mostly, a dump of a db is wanted in SQL. In case of emergency import file. But some people do not comprehend SQL or their SQL doesn&#8217;t like your SQL and everything goes down the drain. So there is the CSV or Comma-separated values file. As the name says, it separates the values by commas (and more if needed). Since it&#8217;s so dead simple, you will get a lot of different tools and program languages that will make life easy for you to re-import or just search in it. Microsoft Excel and Openoffice Calc both can handle the format as well, so for a quick look, this will do very nicely.</p>
<p>But there is no simple &#8211;csv switch in mysqldump, your weapon of choice for these tasks. So here the command that will allow you to do what you are after:</p>
<p><code>mysqldump -p -u USER -T DIRECTORY --fields-enclosed-by=\" --fields-terminated-by=, DATABASE</code></p>
<p>So this is the short version, and here what it all means:</p>
<ul>
<li>-p : Asks for a password, as most users have one. If you don&#8217;t specify this on a database with a user/password, it will error</li>
<li>-u USER : Replace USER with your actual username to connect to the database.</li>
<li>-T DIRECTORY : This creates a tab delimited file. Not what we wanted but it&#8217;s the base we need.</li>
<li>&#8211;fields-enclosed-by=\&#8221; : Will add &#8221; characters around the fields. This will allow CSV implementations to find everything that fits together. You will need that backslash or it wont run.</li>
<li>&#8211;fields-terminated-by=, : The so much sought after comma. This replaces the tab and puts a comma in its place, which, you guessed it, creates the CSV file.</li>
<li>DATABASE : Well you know, the thing this is all about&#8230;</li>
</ul>
<p>To actually be able to do it though, you will need the FILE privilege on this database. Armed with this, you should be able to do your CSV exports easy now.</p>
 <p>Feel free to Flattr this post at <a href="http://flattr.com/" title="Flattr" target="_blank" onclick="pageTracker._trackPageview('/outgoing/flattr.com/?referer=');">flattr.com</a>, if you like it.</p> <p><a href="http://flattr.com/" title="Flattr" target="_blank" onclick="pageTracker._trackPageview('/outgoing/flattr.com/?referer=');"><img src="http://christianriesen.com/wp-content/plugins/flattrss/button-compact-static-100x17.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://christianriesen.com/2009/06/creating-a-mysql-dump-in-csv-format/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
