<?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>Libre Things &#187; MySQL</title>
	<atom:link href="http://positon.org/tag/mysql/feed" rel="self" type="application/rss+xml" />
	<link>http://positon.org</link>
	<description></description>
	<lastBuildDate>Tue, 23 Feb 2016 20:01:11 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.7.1</generator>
	<item>
		<title>Import CSV file to MySQL</title>
		<link>http://positon.org/import-csv-file-to-mysql</link>
		<comments>http://positon.org/import-csv-file-to-mysql#comments</comments>
		<pubDate>Sun, 13 Nov 2011 20:32:00 +0000</pubDate>
		<dc:creator><![CDATA[dooblem]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[csv]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://positon.org:81/?p=112</guid>
		<description><![CDATA[Here is the little sh script I made to do that. The LOAD DATA INFILE command exists but is not capable of creating the table structure. #!/bin/sh MYSQL_ARGS=&#34;--defaults-file=/etc/mysql/debian.cnf&#34; DB=&#34;mbctest&#34; DELIM=&#34;;&#34; CSV=&#34;$1&#34; TABLE=&#34;$2&#34; [ &#34;$CSV&#34; = &#34;&#34; -o &#34;$TABLE&#34; = &#34;&#34; ] &#38;&#38; echo &#34;Syntax: $0 csvfile tablename&#34; &#38;&#38; exit 1 FIELDS=$(head -1 &#34;$CSV&#34; &#124; sed [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Here is the little sh script I made to do that. The LOAD DATA INFILE command exists but is not capable of creating the table structure.</p>
<pre>
#!/bin/sh

MYSQL_ARGS=&quot;--defaults-file=/etc/mysql/debian.cnf&quot;
DB=&quot;mbctest&quot;
DELIM=&quot;;&quot;

CSV=&quot;$1&quot;
TABLE=&quot;$2&quot;

[ &quot;$CSV&quot; = &quot;&quot; -o &quot;$TABLE&quot; = &quot;&quot; ] &amp;&amp; echo &quot;Syntax: $0 csvfile tablename&quot; &amp;&amp; exit 1

FIELDS=$(head -1 &quot;$CSV&quot; | sed -e 's/'$DELIM'/` varchar(255),\n`/g' -e 's/\r//g')
FIELDS='`'&quot;$FIELDS&quot;'` varchar(255)'

#echo &quot;$FIELDS&quot; &amp;&amp; exit

mysql $MYSQL_ARGS $DB -e &quot;
DROP TABLE IF EXISTS $TABLE;
CREATE TABLE $TABLE ($FIELDS);

LOAD DATA INFILE '$(pwd)/$CSV' INTO TABLE $TABLE
FIELDS TERMINATED BY '$DELIM'
IGNORE 1 LINES
;
&quot;
</pre>
<p><a href="http://dev.mysql.com/doc/refman/5.1/en/load-data.html" title="http://dev.mysql.com/doc/refman/5.1/en/load-data.html">http://dev.mysql.com/doc/refman/5.1/en/load-data.html</a></p>
<p>(See comment: &#8220;Posted by John Swapceinski on September 5 2011 5:33am&#8221;)</p>
]]></content:encoded>
			<wfw:commentRss>http://positon.org/import-csv-file-to-mysql/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>A very simple mysqldump script to backup your databases</title>
		<link>http://positon.org/a-very-simple-mysqldump-script-to-backup-your-databases</link>
		<comments>http://positon.org/a-very-simple-mysqldump-script-to-backup-your-databases#comments</comments>
		<pubDate>Sun, 13 Mar 2011 20:42:00 +0000</pubDate>
		<dc:creator><![CDATA[dooblem]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[shell script]]></category>

		<guid isPermaLink="false">http://positon.org:81/?p=110</guid>
		<description><![CDATA[Here are some lines I&#8217;m using to backup my MySQL databases on my Debian server: #!/bin/sh # This will dump all your databases DATE=$(date +%Y%m%d%H%M) for DB in $(echo &#34;show databases&#34; &#124; mysql --defaults-file=/etc/mysql/debian.cnf -N) do mysqldump --defaults-file=/etc/mysql/debian.cnf $DB &#62; /backup/mysql/${DB}_${DATE}.sql gzip /backup/mysql/${DB}_${DATE}.sql done # purge old dumps find /backup/mysql/ -name &#34;*.sql*&#34; -mtime +8 -exec [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Here are some lines I&#8217;m using to backup my MySQL databases on my Debian server:</p>
<pre>
#!/bin/sh
# This will dump all your databases

DATE=$(date +%Y%m%d%H%M)

for DB in $(echo &quot;show databases&quot; | mysql --defaults-file=/etc/mysql/debian.cnf -N)
do
        mysqldump --defaults-file=/etc/mysql/debian.cnf $DB &gt; /backup/mysql/${DB}_${DATE}.sql

        gzip /backup/mysql/${DB}_${DATE}.sql
done

# purge old dumps
find /backup/mysql/ -name &quot;*.sql*&quot; -mtime +8 -exec rm -vf {} \;
</pre>
<p>You can run it in a cron:</p>
<pre>
11 1 * * * /usr/local/bin/mysqldump.sh &gt; /tmp/mysqldump.log
</pre>
<p>This way any error displayed by the script will be sent by mail to the root user (mail address in <code>/etc/aliases</code>).</p>
<p>If you are not under Debian and there is no password file in /etc/mysql, you should create such file.</p>
]]></content:encoded>
			<wfw:commentRss>http://positon.org/a-very-simple-mysqldump-script-to-backup-your-databases/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
