Establish-Connection-to-mysql-database

Establish-Connection-to-mysql-database

I am going to explain stepwise how to access a MySQL database on LINUX machine through Windows.

1. Install mysql-connector-odbc-5.1.5-win32.msi setup on your machine.
2. Add a Data Source Name (DSN) using ODBC DataSource Administrator.
3.Goto Control Panel-->Administrative tools.
4.Select Data Sources (ODBC).
5.It will open up ODBC DataSource Administrator window.
6.Click Add-->Select MySQL ODBC 5.1 Driver from the list.ClickFinish.
7.Specify the following connection parammeters,
______________________________________________
Data Source Name:Your new DNS name.
Description: any
Server:
IP Address of the LINUX machine.
Port: 3306 by default.
User
:LINUX Server's mysql username.
Password:
LINUX Server's mysql username.
DataBase:
MySQL Database name.

Test the connection and if successful click OK.
______________________________________________

Now specify the connection string in your application.

string odbc_connectionstr = "DSN=Mysource;
Server=100.200.3.50;
Database=mydbname;
User=myusername;Password=mypassword;Port=3306";
________________________________________________
Also, Include Namespace in your application:
using System.Data.Odbc;
________________________________________________

0 comments: