Difference between revisions of "Odbc"

From ArchWiki
Jump to: navigation, search
(MySQL and ODBC)
 
(89 intermediate revisions by 16 users not shown)
Line 1: Line 1:
'''ODBC MySQL'''
+
#REDIRECT [[Open Database Connectivity]]
 
 
This document shows how to set up ODBC in Arch first on your localhost and then extends the steps to setup ODBC on
 
a server.
 
 
 
 
 
 
 
http://mail.easysoft.com/pipermail/unixodbc-support/2004-August/000111.html
 
this was the tutorial and here are the steps we did to get around the error messages
 
 
 
1)created the odbc.ini and .odbc.ini
 
and created odbcinst.ini and .odbcinst.ini in the home dir
 
 
 
2) made a symlink
 
ls -s /usr/lib/libmyodbc3-3.51.12.so ./libmyodbc.so
 
http://help.hardhathosting.com/question.php/95
 
 
 
3)two files version names are wrong, so cp and rename
 
i.e. cp libcrypto.so.0.9.8 libcrypto.so.0.9.7
 
 
 
 
 
4)Server=localhost
 
 
 
 
 
5)mysql.sock is in /tmp/
 
 
 
Here are the files
 
__________________________________
 
/etc/odbc.ini
 
 
 
 
 
[MySQL-test]
 
Description    = MySQL database test
 
Driver          = MySQL
 
Server          = localhost
 
Database       = test
 
Port            = 3306
 
Socket          = /tmp/mysql.sock
 
Option          =
 
Stmt            =
 
 
 
 
 
_________________________
 
/etc/odbcinst.ini
 
 
 
[MySQL]
 
Description    = ODBC Driver for MySQL
 
Driver          = /usr/lib/libmyodbc.so
 
Setup          = /usr/lib/libodbcmyS.so
 
FileUsage      = 1
 
 
 
 
 
 
 
 
 
___________
 
For a remote connection there are a couple of extra steps
 
1) hosts.all needs "mysqld: ALL"
 
2) verify port 3306 is listening by "netstat -ant" in shell
 
3) grant permission to individual IP in mysql
 
http://www.cyberciti.biz/nixcraft/vivek/blogger/2006/03/how-do-i-enable-remote-access-to-mysql.php
 
Grant access to new database
 
If you want to add new database called foo for user bar and remote IP 202.54.10.20 then you need to type following commands at mysql> prompt:
 
 
 
mysql> CREATE DATABASE foo;
 
mysql> GRANT ALL ON foo.* TO bar@'202.54.10.20' IDENTIFIED BY 'PASSWORD';
 
Grant access to existing database
 
Let us assume that you are always making connection from remote IP called 202.54.10.20 for database called webdb for user webadmin then you need to grant access to this IP address. At mysql> prompt type following command for existing database:
 
 
 
mysql> update db set Host='202.54.10.20' where Db='webdb';
 
mysql> update user set Host='202.54.10.20' where user='webadmin';
 
 
 
 
 
From remote system type command:
 
 
 
$ mysql -u webadmin –h 65.55.55.2 –p
 
You can also use telnet to connect to port 3306 for testing purpose:
 
 
 
$ telnet 65.55.55.2 3306
 
 
 
____________________________________________________
 
[MySQL-test]
 
Description    = MySQL database test
 
Driver          = MySQL
 
Server          = 192.168.0.2
 
Trace          = Off
 
TraceFile      = stderr
 
Database        =foo
 
Port            = 3306
 
USER            = adowns
 
Password        = boston
 
Socket          = /tmp/mysql.sock
 
Option          =
 
Stmt            =
 

Latest revision as of 10:32, 21 February 2015