<?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>Riding The Breeze &#187; MySQL</title>
	<atom:link href="http://www.iliveinperego.com/category/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.iliveinperego.com</link>
	<description>Yes !</description>
	<lastBuildDate>Tue, 31 Jan 2012 22:06:52 +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 Mysql Database on remote FTP Server</title>
		<link>http://www.iliveinperego.com/2011/06/backup-mysql-ftp-server/</link>
		<comments>http://www.iliveinperego.com/2011/06/backup-mysql-ftp-server/#comments</comments>
		<pubDate>Mon, 20 Jun 2011 20:42:39 +0000</pubDate>
		<dc:creator>hpatoio</dc:creator>
				<category><![CDATA[Computer]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.iliveinperego.com/?p=291</guid>
		<description><![CDATA[Here a simple script to backup all your mysql database on a remote FTP server. The script weekly overwrite the backup so you have full backup of your DBs for the last 6 days and your FTP server doesn&#039;t run out of space. #!/bin/sh &#160; BACKUP=&#34;/path/to/temp/dir/$$&#34; &#160; DAY=$&#40;date +&#34;%a&#34;&#41; &#160; ### MySQL Setup ### MUSER=&#34;root&#34; [...]]]></description>
			<content:encoded><![CDATA[<p>Here a simple script to backup <strong>all</strong> your mysql database on a remote FTP server. The script weekly overwrite the backup so you have full backup of your DBs for the last 6 days and your FTP server doesn&#039;t run out of space.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
&nbsp;
<span style="color: #007800;">BACKUP</span>=<span style="color: #ff0000;">&quot;/path/to/temp/dir/$$&quot;</span>
&nbsp;
<span style="color: #007800;">DAY</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #ff0000;">&quot;%a&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">### MySQL Setup ###</span>
<span style="color: #007800;">MUSER</span>=<span style="color: #ff0000;">&quot;root&quot;</span>
<span style="color: #007800;">MPASS</span>=<span style="color: #ff0000;">&quot;your_root_password&quot;</span>
<span style="color: #007800;">MHOST</span>=<span style="color: #ff0000;">&quot;localhost&quot;</span>
<span style="color: #007800;">MYSQL</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$(which mysql)</span>&quot;</span>
<span style="color: #007800;">MYSQLDUMP</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$(which mysqldump)</span>&quot;</span>
<span style="color: #007800;">GZIP</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$(which gzip)</span>&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">### FTP server Setup ###</span>
<span style="color: #007800;">FTPUSER</span>=<span style="color: #ff0000;">&quot;ftp_username&quot;</span>
<span style="color: #007800;">FTPPASS</span>=<span style="color: #ff0000;">&quot;ftp_password&quot;</span>
<span style="color: #007800;">FTPHOST</span>=<span style="color: #ff0000;">&quot;ftp_host&quot;</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #660033;">-p</span> <span style="color: #007800;">$BACKUP</span>
&nbsp;
<span style="color: #666666; font-style: italic;">### Start MySQL Backup ###</span>
<span style="color: #666666; font-style: italic;"># Get all databases name</span>
<span style="color: #007800;">DBS</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$($MYSQL -u $MUSER -h $MHOST -p$MPASS -Bse 'show databases')</span>&quot;</span>
<span style="color: #000000; font-weight: bold;">for</span> db <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #007800;">$DBS</span>
<span style="color: #000000; font-weight: bold;">do</span>
 <span style="color: #007800;">FILE</span>=<span style="color: #007800;">$BACKUP</span><span style="color: #000000; font-weight: bold;">/</span>$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #ff0000;">&quot;%a&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>-<span style="color: #007800;">$db</span>.gz
 <span style="color: #007800;">$MYSQLDUMP</span> <span style="color: #660033;">-u</span> <span style="color: #007800;">$MUSER</span> <span style="color: #660033;">-h</span> <span style="color: #007800;">$MHOST</span> -p<span style="color: #007800;">$MPASS</span> <span style="color: #007800;">$db</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #007800;">$GZIP</span> <span style="color: #660033;">-9</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #007800;">$FILE</span>
 <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Saving &quot;</span><span style="color: #007800;">$db</span><span style="color: #ff0000;">&quot; to &quot;</span><span style="color: #007800;">$FILE</span>
<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
<span style="color: #666666; font-style: italic;">### Dump backup using FTP ###</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Sending file via FTP&quot;</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">ftp</span> <span style="color: #660033;">-ni</span> <span style="color: #007800;">$FTPHOST</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>ftp.worked <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>ftp.failed <span style="color: #000000; font-weight: bold;">&lt;&lt;</span>END_SCRIPT
quote USER <span style="color: #007800;">$FTPUSER</span>
quote PASS <span style="color: #007800;">$FTPPASS</span>
lcd <span style="color: #007800;">$BACKUP</span>
binary
mput <span style="color: #000000; font-weight: bold;">*</span>.gz
quit
END_SCRIPT
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>ftp.failed <span style="color: #7a0874; font-weight: bold;">&#93;</span> 
<span style="color: #000000; font-weight: bold;">then</span>
   <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Problem while sendig file ... &quot;</span>
   <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>ftp.failed <span style="color: #000000; font-weight: bold;">|</span> mail <span style="color: #660033;">-s</span> <span style="color: #ff0000;">&quot;Problem while backup&quot;</span> yourmail<span style="color: #000000; font-weight: bold;">@</span>yourdomain.com
<span style="color: #000000; font-weight: bold;">else</span>
   <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;File sent successfully ... &quot;</span>
   <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Deleting temporary backup direatory&quot;</span>
   <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$BACKUP</span>
   <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> <span style="color: #007800;">$BACKUP</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></div></div>

<p>Once you have set the parameters and saved the file edit your cron for a nightly backup and add a line like</p>
<pre>
# FTP backup
0 2 * * * /path/to/your/file/do_backup.sh > /path/to/your/file/cron.log
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.iliveinperego.com/2011/06/backup-mysql-ftp-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSV export from MySQL</title>
		<link>http://www.iliveinperego.com/2007/09/csv-export-from-mysql/</link>
		<comments>http://www.iliveinperego.com/2007/09/csv-export-from-mysql/#comments</comments>
		<pubDate>Sat, 15 Sep 2007 15:17:36 +0000</pubDate>
		<dc:creator>simone</dc:creator>
				<category><![CDATA[Computer]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Things I forget]]></category>

		<guid isPermaLink="false">http://www.iliveinperego.com/csv-export-from-mysql</guid>
		<description><![CDATA[If you have access on the machine with MySQL and you need to export all tables in a database you can use: hpatoio@namazu:~$ mysqldump -uroot -p DATABASE_NAME -T '/home/simone/export_csv' --fields-terminated-by "," --fields-enclosed-by '"' --lines-terminated-by "\n" the script will create a files for each table of the DB and will place it in export_csv. If you [...]]]></description>
			<content:encoded><![CDATA[<p>If you have access on the machine with MySQL and you need to export all tables in a database you can use:</p>
<p><code>hpatoio@namazu:~$ mysqldump -uroot -p DATABASE_NAME -T '/home/simone/export_csv' --fields-terminated-by "," --fields-enclosed-by '"' --lines-terminated-by "\n"</code></p>
<p>the script will create a files for each table of the DB and will place it in <em>export_csv</em>.</p>
<p>If you need to export a custom resultset or you need to export data from a remote MySQL server on your machine you can use this command :</p>
<p><code>hpatoio@namazu:~$ mysql -uroot -h HOSTNAME -p DATABASE_NAME -B -e "select field1,field2 ... fieldX from \`TABLE_NAME\`;" | sed 's/\t/","/g;s/^/"/;s/$/"/;s/\n//g' &gt; my_export.csv</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.iliveinperego.com/2007/09/csv-export-from-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Microsoft Access to MySQL &#124; Online converter</title>
		<link>http://www.iliveinperego.com/2007/09/access-2-mysql-online-converter/</link>
		<comments>http://www.iliveinperego.com/2007/09/access-2-mysql-online-converter/#comments</comments>
		<pubDate>Tue, 11 Sep 2007 07:41:17 +0000</pubDate>
		<dc:creator>simone</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.iliveinperego.com/access-2-mysql-online-converter</guid>
		<description><![CDATA[Amazing online tool to convert MDB Microsoft Access file to MySQL SQL scripts ! Check it out -> http://www.mdb2mysql.com/]]></description>
			<content:encoded><![CDATA[<p>Amazing <strong>online</strong> tool to convert  MDB Microsoft Access file to MySQL SQL scripts !</p>
<p>Check it out -> <a href="http://www.mdb2mysql.com/">http://www.mdb2mysql.com/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.iliveinperego.com/2007/09/access-2-mysql-online-converter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ops &#8230;</title>
		<link>http://www.iliveinperego.com/2006/10/ops/</link>
		<comments>http://www.iliveinperego.com/2006/10/ops/#comments</comments>
		<pubDate>Sun, 08 Oct 2006 21:44:42 +0000</pubDate>
		<dc:creator>simone</dc:creator>
				<category><![CDATA[Computer]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Things I forget]]></category>

		<guid isPermaLink="false">http://www.iliveinperego.com/ops</guid>
		<description><![CDATA[Oh no ! It happend again !! The sysadmin turned on the gpc_magic_quotes and you got the DB full of \&#039; Here a fast way to get back the correct values. UPDATE table_name SET field_name = REPLACE(field_name,&#039;\&#034;&#039;,&#034;&#034;)]]></description>
			<content:encoded><![CDATA[<p>Oh no ! It happend again !!</p>
<p>The sysadmin turned on the gpc_magic_quotes and you got the <acronym title="Database">DB</acronym> full of \&#039;</p>
<p>Here a fast way to get back the correct values.</p>
<blockquote><p>
UPDATE <em>table_name</em> SET <em>field_name</em> = REPLACE(<em>field_name</em>,&#039;\&#034;&#039;,&#034;&#034;)
 </p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.iliveinperego.com/2006/10/ops/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Access Mysql from other machines</title>
		<link>http://www.iliveinperego.com/2006/08/access-mysql-from-other-machine/</link>
		<comments>http://www.iliveinperego.com/2006/08/access-mysql-from-other-machine/#comments</comments>
		<pubDate>Tue, 29 Aug 2006 20:46:54 +0000</pubDate>
		<dc:creator>simone</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Things I forget]]></category>

		<guid isPermaLink="false">http://www.iliveinperego.com/access-mysql-from-other-machine</guid>
		<description><![CDATA[For security reason, MySQL doesn&#039;t allow access from other computer. If you try to connect with a MySQL administration client like MySQL Administrator you will get a Mysql Error Number 2003. All this operations modify system settings, so they must be executed with root privileges If you want connect from a computer in your LAN [...]]]></description>
			<content:encoded><![CDATA[<p>For security reason, MySQL doesn&#039;t allow access from other computer.<br />
If you try to connect with a MySQL administration client like <a href="http://www.mysql.com/products/tools/administrator/">MySQL Administrator</a> you will get a <em>Mysql Error Number 2003</em>.</p>
<p>All this operations modify system settings, so they must be executed with root privileges</p>
<p>If you want connect from a computer in your LAN to your mysql server you have to :</p>
<h3>1) Edit your MySQL configuration file</h3>
<p><code>root@namazu:~#sudo vi /etc/mysql/my.conf</code><br />
and change the line<br />
bind-address = 127.0.0.1<br />
with<br />
bind-address = 192.168.178.100</p>
<p>Now, to apply changes you have to reload the MySQL server<br />
<code>root@namazu:~#sudo /etc/init.d/mysql restart</code><br />
No MySQL listen on your external interface, to verify that the server is up and accept connection type</p>
<p><code>root@namazu:~#telnet 192.168.178.100 3306</code></p>
<p>and you should get:</p>
<p><code>Trying 192.168.178.100...<br />
Connected to 192.168.178.100.<br />
Escape character is '^]'.<br />
@<br />
5.0.75-0ubuntu10.2</code></p>
<h3>2) Give grants</h3>
<p>Now MySQL is reachable on the &#034;network&#034; level, we have to enable access to databases.</p>
<p>Let&#039;s access MySQL with the mysql client, we still use <em>localhost</em> because we don&#039;t have privileges to access MySQL from others hosts yet.</p>
<p><code>root@namazu:~#mysql -u<em>root</em> -p<em>myRootPass</em> -h localhost </code></p>
<p>Welcome to the MySQL monitor.  Commands end with ; or \g. Your MySQL connection id is 7 to server version: 5.0.22-Debian_0ubuntu6.06-log  Type &#039;help;&#039; or &#039;\h&#039; for help. Type &#039;\c&#039; to clear the buffer.</p>
<p>Modify access privileges to the server</p>
<p><code>mysql&gt;GRANT ALL PRIVILEGES ON <em>DB_NAME</em> TO '<em>USERNAME</em>'@'<em>HOST</em>' IDENTIFIED BY<br />
'<em>PASSWORD</em>';</code></p>
<p><acronym title="Nota bene">N.B.</acronym></p>
<ul>
<li>if you want to give access from any host set <em>HOST</em> to &#039;%&#039;</li>
<li>if you want to grant access to all the DBs set <em>DB_NAME</em> to *.*</li>
</ul>
<p>So, for instance, with this command :</p>
<p><code>mysql&gt;GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'foopass';</code></p>
<p>we allow root (whose pass is <em>foopass</em>) to access all databases whichever host.</p>
<p>Exit the client</p>
<p><code>mysql&gt;exit</code></p>
<p>Reload the privileges</p>
<p><code>root@namazu:~#mysqladmin reload</code></p>
<p>For more info on GRANT command: <a title="GRANT Syntax | MySQL Reference Manual" href="http://dev.mysql.com/doc/refman/5.0/en/grant.html">GRANT Syntax on MySQL Reference Manual</a></p>
<p>Have fun &#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.iliveinperego.com/2006/08/access-mysql-from-other-machine/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

