Sunday, December 22, 2013

Connect ODBC to MySQL on Ubuntu Server 12.04.3 LTS

Connect ODBC to MySQL on Ubuntu Server 12.04.3 LTS

Sometime the application is connect to MySQL server is not only web application, it is windows native application.



1.  Install LAMP and PhpMyAdmin on Ubuntu server
  • Install LAMP Stack (Linux,Apache, Mysql, PHP) with command below:
sudo apt-get install lamp-server^
  • Install PHP5 (Some applications require other PHP5 mods) with command:
sudo apt-get install php5 php5-gd php5-mysql php5-curl php5-cli php5-cgi php5-dev
  • Install phpmyadmin
sudo apt-get install phpmyadmin
Watch video Install LAMP Server in Ubuntu Server 12.04.3 LTS


2.  Test LAMP server
  • Open browser and type the server IP address in the address box
  • Type the server IP address and "/phpmyadmin" in the address box
Watch video test LAMP Server


3. Configuration MySQL to listening from externally 
  • Removing the line "bind-address 127.0.0.1" from "/etc/mysql/my.cnf" with command :
sudo nano /etc/mysql/my.cnf
  • Restart MySQL server with command :
sudo /etc/init.d/mysql restart
Watch video configuration MySQL to listening from externally


4.  Add user to MySQL
  • Connect to MySQL with command :
mysql -u root -p
          and type your password
  • Create local user (demo1) with command :
mysql> CREATE USER 'demo1'@'localhost' IDENTIFIED BY 'some_pass';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'demo1'@'localhost' WITH GRANT OPTION;
  • Create remote user (demo1) with command :
mysql> CREATE USER 'demo1'@'%' IDENTIFIED BY 'some_pass';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'demo1'@'%' WITH GRANT OPTION;
Watch video create MySQL user




5.  Connect to MySQL using ODBC on Windows 7


If MySQL connector/ODBC - Error 1918 during installation process you can fix it by copying
"C:\Windows\System32\msvcr100_clr0400.dll" to "msvcr100.dll" and continue with the install.

  • Go to Control Panel > System and Security > Administrative Tools

  • Open "Data Sources (ODBC)"


  • Click "Add"
  • Select "MySQL ODBC 5.2 Unicode Driver" and click "Finish"
  • MySQL connector windows will appear, fill in all data and click "Test" button

  • "Connection successful" you can connect native application to ODBC MySQL conector
Watch video connect to MySQL using ODBC on Windows 7


Tips :
You can add mysql user by phpmyadmin
Watch video