<?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>Caneblu.com &#187; Mysql</title>
	<atom:link href="http://www.caneblu.com/tag/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.caneblu.com</link>
	<description>Solo un altro blog targato WordPress</description>
	<lastBuildDate>Mon, 10 May 2010 20:32:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>MySQL backup from command line</title>
		<link>http://www.caneblu.com/2010/02/mysql-backup-from-command-line/</link>
		<comments>http://www.caneblu.com/2010/02/mysql-backup-from-command-line/#comments</comments>
		<pubDate>Sun, 14 Feb 2010 16:17:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mysql]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://www.caneblu.com/?p=123</guid>
		<description><![CDATA[It may be useful to make a backup of a specific database through the command line. Surely it is easier to use tools like phpMyAdmin, but in case of emergency or because you prefer use the shell, this info is certainly useful. The executable that performs the operation is &#8220;mysqldump&#8221; which is usually installed with [...]]]></description>
			<content:encoded><![CDATA[<p>It may be useful to make a backup of a specific database through the command line. Surely it is easier to use tools like <strong>phpMyAdmin</strong>, but in case of emergency or because you prefer use the shell, this info is certainly useful. The executable that performs the operation is &#8220;<strong>mysqldump</strong>&#8221; which is usually installed with the MySQL server.</p>
<p><code>mysqldump -h localhost -u username -p database_name > database_backup.sql</code></p>
<p>Obviously the parameters changed accordingly, localhost should be fine considering the use of the shell, while database_name username must be adjusted accordingly. After the sign > is the name chosen at your discretion. Once given the command will be prompted for a password to access the database to its content.</p>
<p>Can also directly produce a compressed slightly by changing the syntax as follows:</p>
<p><code>mysqldump -h localhost -u username -p database_name | gzip -9 > database_backup.sql.gz</code></p>
<p>where performs gzip compression (-9 parameter indicates the best compression possible), this is useful if you download the file through the Internet.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.caneblu.com/2010/02/mysql-backup-from-command-line/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL sample connection</title>
		<link>http://www.caneblu.com/2009/01/mysql-sample-connection/</link>
		<comments>http://www.caneblu.com/2009/01/mysql-sample-connection/#comments</comments>
		<pubDate>Sun, 04 Jan 2009 17:07:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Mysql]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.caneblu.com/caneblu/?p=23</guid>
		<description><![CDATA[Pre-requisites: Database host or IP Database name Username and password access of db. First we need to declare some critical data like username and password, so i strongly recommended to store this value into a different file where php will ask tables and data, this for security reason. In the php convension, usually we make [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Pre-requisites:</strong><br />
Database host or IP<br />
Database name<br />
Username and password access of db.</p>
<p>First we need to declare some critical data like username and password, so i strongly recommended to store this value into a different file where php will ask tables and data, this for security reason.</p>
<p>In the php convension, usually we make a file called config.inc.php, because the .inc between the file name and real extension, dont show nothing if directly called to your browser.</p>
<p>Let&#8217;s make this file usually called config.inc.php</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">      <span style="color: #000000; font-weight: bold;">&lt;?php</span>
      <span style="color: #666666; font-style: italic;">//database parameters</span>
      <span style="color: #000088;">$db_host</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;localhost&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//usually localhost, but can be an IP</span>
      <span style="color: #000088;">$db_user</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;myusername&quot;</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$db_password</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;mypassword&quot;</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$db_name</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;mydatabasename&quot;</span><span style="color: #339933;">;</span>
      <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Now we must pass to php this values, if you are planning a project, usually is a good idea to make next step to a file called database.php and perform the connection.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">      <span style="color: #000000; font-weight: bold;">&lt;?php</span>
      <span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;config.inc.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #666666; font-style: italic;">//now check our usr/pass credentials</span>
      <span style="color: #000088;">$db</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_connect</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$db_host</span><span style="color: #339933;">,</span> <span style="color: #000088;">$db_user</span><span style="color: #339933;">,</span> <span style="color: #000088;">$db_password</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$db</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #009900;">&#41;</span>
      <span style="color: #990000;">die</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;put here an error message&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #666666; font-style: italic;">//now we see if database name can be read/write</span>
      <span style="color: #990000;">mysql_select_db</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$db_name</span><span style="color: #339933;">,</span> <span style="color: #000088;">$db</span><span style="color: #009900;">&#41;</span>
      or <span style="color: #990000;">die</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ERROR: your parameteres are wrong&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>With <em>mysql_connect</em> your have ask a connection to database server with your username and password, usually on shared service, your credentials give access to one database, so the server must reply if you have a valid account on it. Be careful, the variables <em>$db_host, $db_user, $db_password</em> must be passed in the order of example above.</p>
<p>With <em>mysq_select_db</em> you ask the permission to read/write on database name, with previous credentials.<br />
Both functions are native PHP functions, and they can perform only a TRUE or FALSE, no database data is exchanged yet.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.caneblu.com/2009/01/mysql-sample-connection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
