$sudo apt-get install libmyodbc
$sudo apt-get install unixodbc-dev
Después necesitamos agregar el driver de mysql a unixodbc
abre el archivo odbc.ini ya agrega esto:
$sudo gedit /etc/odbcinst.ini
[MySQL]
Description = MySQL driver
Driver = /usr/lib/odbc/libmyodbc.so
Setup = /usr/lib/odbc/libodbcmyS.so
FileUsage = 1
despues necesitamos agregar la base de datos a la que se quiere conectar
abre el archivo odbc.ini:
$sudo gedit /etc/odbc.ini
[ODBC Data Sources]
test = Connector/ODBC 3.51 Driver DSN
[test]
Driver = /usr/lib/odbc/libmyodbc.so
Description = Connector/ODBC 3.51 Driver DSN
Server = localhost
DSN = test
Port = 3306
Socket = /var/lib/mysql/mysql.sock
User = DB_USER_NAME
Password = DB_PASSWORD
Database = DB_NAME
ServerType = MySQL
Option =
TraceFile = /var/log/mysql_test_trace.log
Trace = 0
[Default]
Driver = /usr/lib/odbc/libmyodbc.so
Description = Connector/ODBC 3.51 Driver DSN
Server = localhost
DSN = test
Port = 3306
Socket = /var/lib/mysql/mysql.sock
User = DB_USER_NAME
Password = DB_PASSWORD
Database = DB_NAME
ServerType = MySQL
Option =
TraceFile = /var/log/mysql_test_trace.log
Trace = 0
Y damos de alta al driver con este template, crea un archivo donde quieras:
template1.txt:
[MySQL]
Description = MySQL database
Driver = MySQL
SERVER = localhost
USER = DB_USER_NAME
PASSWORD = DB_PASSWORD
PORT = 3306
DATABASE = DB_NAME
Y para terminar este comando en la terminal
$ odbcinst -i -s -f template1.txt