<?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>Camilo Lozano III &#187; remote</title>
	<atom:link href="http://camilord.kagayan.com/tag/remote/feed/" rel="self" type="application/rss+xml" />
	<link>http://camilord.kagayan.com</link>
	<description>Linux for Servers, Macintosh for Graphics and Windows for Solitair...</description>
	<lastBuildDate>Sat, 24 Jul 2010 13:07:33 +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>Visual C#: Connecting to MySQL remotely</title>
		<link>http://camilord.kagayan.com/2009/04/13/visual-c-connecting-to-mysql-remotely/</link>
		<comments>http://camilord.kagayan.com/2009/04/13/visual-c-connecting-to-mysql-remotely/#comments</comments>
		<pubDate>Sun, 12 Apr 2009 21:29:04 +0000</pubDate>
		<dc:creator>Camilo III</dc:creator>
				<category><![CDATA[Info.Tech]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Visual C#]]></category>
		<category><![CDATA[connect]]></category>
		<category><![CDATA[connecting remotely]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[remote]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[visual C#]]></category>

		<guid isPermaLink="false">http://camilord.kagayan.com/?p=190</guid>
		<description><![CDATA[I have a current project that connects to a remote database server using Visual C# as client window application. So before I started my project, I tested it if it is possible to connect and the result, it does connect. For those does who failed to solve this problem, here&#8217;s my tutorial/guide. Test Project Requirements:]]></description>
			<content:encoded><![CDATA[<p>I have a current project that connects to a remote database server using Visual C# as client window application. So before I started my project, I tested it if it is possible to connect and the result, it does connect. For those does who failed to solve this problem, here&#8217;s my tutorial/guide.</p>
<p><strong>Test Project Requirements:</strong></p>
<ul>
<li>VMware Workstation 5.5</li>
<li>CentOS 4.4</li>
<li>Visual C# Express Edition</li>
<li>MySQL Data Connector .Net v1.0.7</li>
</ul>
<p><strong>Scenario:</strong></p>
<p>The client&#8217;s OS is MS Windows XP and the server is CentOS Linux. The client will connect to the Linux server to query and process some transaction. But in the sample code, it demonstrate only how to connect remotely in the server. My server&#8217;s IP address is <strong>192.168.10.117</strong> and a MySQL port of <strong>3306</strong> (default port).</p>
<p><strong>Screenshots:</strong></p>
<p style="text-align: center;">
<a href="http://camilord.kagayan.com/wp-content/gallery/tutorials-images/mysqlRemote1.jpg" title="" class="shutterset_singlepic97" >
	<img class="ngg-singlepic ngg-center" src="http://camilord.kagayan.com/wp-content/gallery/cache/97__287x226_mysqlRemote1.jpg" alt="mysqlRemote1.jpg" title="mysqlRemote1.jpg" />
</a>
</p>
<p><strong>Step 1:</strong></p>
<p>Setup the Linux server, be sure you already installed MySQL server. In our case, we use VMware and a CentOS 4.4 is installed. For installation help, google it! <img src='http://camilord.kagayan.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />  The first thing to do is configure your IP tables by using <em><strong>iptables</strong></em> command. see illustration below;</p>
<p style="text-align: center;">
<a href="http://camilord.kagayan.com/wp-content/gallery/tutorials-images/iptables1.jpg" title="" class="shutterset_singlepic95" >
	<img class="ngg-singlepic" src="http://camilord.kagayan.com/wp-content/gallery/cache/95__400xfloat=center_iptables1.jpg" alt="iptables1.jpg" title="iptables1.jpg" />
</a>
</p>
<p>If your configuration does not allow foreign connection to your MySQL, then change that and allow it. In real scenario if your server is public, I recommend that you must have a new server which can only be access through local network. Or if cannot afford, just setup well the IP tables that only local connections are allowed. Anyway, here&#8217;s my new IP tables setup in my server;</p>
<p style="text-align: center;">
<a href="http://camilord.kagayan.com/wp-content/gallery/tutorials-images/iptables2.jpg" title="" class="shutterset_singlepic96" >
	<img class="ngg-singlepic" src="http://camilord.kagayan.com/wp-content/gallery/cache/96__400xfloat=center_iptables2.jpg" alt="iptables2.jpg" title="iptables2.jpg" />
</a>
</p>
<p>In MySQL CLI, create a user that can access everywhere. To do this, see sample below;</p>
<p>mysql&gt; GRANT ALL PRIVILEGES ON *.* to &#8216;beasaw&#8217;@'%&#8217; IDENTIFIED BY &#8216;qwerty&#8217;;</p>
<p>Explained: the command shown above is to allow user, <em>beasaw</em>, to access anywhere using a password <em>qwerty</em>.</p>
<p>That&#8217;s it&#8230; server setup completed. <img src='http://camilord.kagayan.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p><strong>Step 2:</strong></p>
<p>Before you create a new project in VCS, test first the connection using the command;</p>
<p><strong>C:\&gt; mysql\bin\mysql -</strong><strong>-host=192.168.10.117 -</strong><strong>-port=3306 -</strong><strong>-user=beasaw -</strong><strong>-password=qwerty</strong></p>
<p>See image below;</p>
<p style="text-align: center;">
<a href="http://camilord.kagayan.com/wp-content/gallery/tutorials-images/cmd_mysql.jpg" title="" class="shutterset_singlepic93" >
	<img class="ngg-singlepic" src="http://camilord.kagayan.com/wp-content/gallery/cache/93__400xfloat=center_cmd_mysql.jpg" alt="cmd_mysql.jpg" title="cmd_mysql.jpg" />
</a>
</p>
<p><strong>Step 3:</strong></p>
<ol>
<li>Open your Visual C# and create a new project, name it to <em>remoteMySQL</em>.</li>
<li>In Form1.cs, layout just like the screenshot above.</li>
<li>Add a reference, <em><strong>MySql.Data.dll</strong> </em>(assumed that you already installed the MySQL data connector .Net v1.0.7)</li>
<li>Add mysql to the project: using MySql.Data.MySqlClient;</li>
<li>Begin your codes, see sample code (download link below)&#8230; <img src='http://camilord.kagayan.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </li>
</ol>
<p style="text-align: center;">
<a href="http://camilord.kagayan.com/wp-content/gallery/tutorials-images/mysqlRemote2.jpg" title="" class="shutterset_singlepic98" >
	<img class="ngg-singlepic ngg-center" src="http://camilord.kagayan.com/wp-content/gallery/cache/98__287x226_mysqlRemote2.jpg" alt="mysqlRemote2.jpg" title="mysqlRemote2.jpg" />
</a>
</p>
<p>That&#8217;s it&#8230; You can create as many applications you want with this method. Like Ticketing System, connecting 10 terminals to the servers simultaneously and etc. And of course, connection varies also to your MySQL server setup. <img src='http://camilord.kagayan.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p><strong>Download:</strong></p>
<p>» <a class="downloadlink" href="http://camilord.kagayan.com/download/mysqlremote_public.zip" title="Versionv1.0.5 downloaded 90 times" >VCS Remote Connect to MySQL Server (90)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://camilord.kagayan.com/2009/04/13/visual-c-connecting-to-mysql-remotely/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
