Created
April 6, 2016 16:07
-
-
Save ziplokk1/18da3744f9fbed214503e99491e69c8f to your computer and use it in GitHub Desktop.
Script to setup odbc packages and install mysql client on linux 14.04LTS.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# RUN AS SUDO | |
# install instructions taken from here http://www.kaffeetalk.de/how-to-setup-and-configure-mysql-with-unixodbc-under-ubuntu-14-04/ | |
# install and configure mysql client | |
sudo apt-get install mysql-client | |
# install odbc drivers | |
sudo apt-get install libmyodbc unixodbc-bin unixodbc-dev | |
# Your mysql driver and setup may be located elsewhere | |
# find them by typing - | |
# find / -name 'lib*odbc*.so' 2> /dev/null | |
DRIVER="/usr/lib/x86_64-linux-gnu/odbc/libmyodbc.so" | |
SETUP="/usr/lib/x86_64-linux-gnu/odbc/libodbcmyS.so" | |
# make the odbcinst.ini file | |
sudo echo -e "[MySQL]\nDescription = Mysql 5.6 odbc connector\nDriver = ${DRIVER}\nSetup = ${SETUP}\nUsageCount = 1" > /etc/odbcinst.ini | |
# Create your DSN | |
DATASOURCENAME="default_dsn" # dont use spaces | |
DESCRIPTION="description" # description of your DSN | |
SERVER="localhost" # or external ip | |
PORT="3306" # or custom port | |
# ignoring socket since we're not installing a server, just a client | |
DATABASE="" # default database or empty | |
READONLY="No" | |
# Create the datasource file | |
sudo echo -e "[${DATASOURCENAME}]\nDescription = ${DESCRIPTION}\nDriver = MySQL\nServer = ${SERVER}\nPort = ${PORT}\nDatabase = ${DATABASE} \nOption = 3\nReadOnly = ${READONLY}" > /etc/odbc.ini | |
sudo odbcinst -i -d -f /etc/odbcinst.ini | |
sudo odbcinst -i -s -l -f /etc/odbc.ini | |
# check if install | |
odbcinst -s -q |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment