Menggunakan UnixODBC

From OnnoWiki
Jump to navigation Jump to search

Di ambil dari http://www.besy.co.uk/debian/how_to_install_and_configure_unixodbc

UnixODBC HOWTO

# aptitude install unixodbc unixodbc-bin unixodbc-dev odbcinst1debian1 libmyodbc

Configure drivers in /etc/odbcinst.ini:

[MySQL]
Description     = MySQL driver for Linux & Win32
Driver          = /usr/lib/odbc/libmyodbc.so
Setup           = /usr/lib/odbc/libodbcmyS.so
FileUsage       = 1
UsageCount      = 1

Configure data-sources in /etc/odbc.ini:

[test]
Description = MySQL Test
Driver      = MySQL
SERVER      = localhost
USER        = username
PASSWORD    = password
PORT        = 3306
DATABASE    = test
Option      = 3

And test:

isql test

If your installing UnixODBC for use with a web-based scripting language like iHTML then you'll need to set the ownership and/or permissions for odbc.ini so that the web-server user can read the file. For standard configurations the user will be www-data, for mpm-itk or su-php configurations you'll need to grant the virtual group read access.


Lebih lengkap tentang isql

**********************************************
* unixODBC - isql                            *
**********************************************
* Syntax                                     *
*                                            *
*      isql DSN [UID [PWD]] [options]        *
*                                            *
* Options                                    *
*                                            *
* -b         batch.(no prompting etc)        *
* -dx        delimit columns with x          *
* -x0xXX     delimit columns with XX, where  *
*            x is in hex, ie 0x09 is tab     *
* -w         wrap results in an HTML table   *
* -c         column names on first row.      *
*            (only used when -d)             *
* -mn        limit column display width to n *
* -v         verbose.                        *
* -lx        set locale to x                 *
* --version  version                         *
*                                            *
* Notes                                      *
*                                            *
*      isql supports redirection and piping  *
*      for batch processing.                 *
*                                            *
* Examples                                   *
*                                            *
*      cat My.sql | isql WebDB MyID MyPWD -w *
*                                            *
*      Each line in My.sql must contain      *
*      exactly 1 SQL command except for the  *
*      last line which must be blank.        *
*                                            *
* Please visit;                              *
*                                            *
*      http://www.unixodbc.org               *
*      pharvey@codebydesign.com              *
*      nick@easysoft.com                     * 
**********************************************