1、修改数据源
vi /etc/apt/source.list
添加 deb http://cz.archive.ubuntu.com/ubuntu lucid main universe
保存
sudo apt-get update
2、安装unixODBC
sudo apt-get install unixODBC
注:没有上一步,会提示没有unixODBC软件包
3、安装数据库
sudo apt-get install mysql-server mysql-client
4、安装mysql的odbc驱动
apt-get install libmyodbc
5、配置(/etc/odbcinst.ini 和 /etc/odbc.ini)
vi /etc/odbcinst.ini
添加
[MySQL]
Description = MySQL
Driver = /usr/lib/i386-linux-gnu/odbc/libmyodbc.so (有可能路径不同,自己搜索一下)
Setup = /usr/lib/i386-linux-gnu/odbc/libodbcmyS.so
FileUsage = 1vi /etc/odbc.ini
[MySql]
Driver = MySQL(与配置的一致)
Description = MySQL ODBC 3.51 Driver DSN
Server = localhost
Port = 3306
User = root
Password = root
Database = test(需要自己创建数据库test)
Option = 3
Socket =
6、测试
isql MySql root root
打印出:
+—————————————+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+—————————————+
After installing a fresh new copy of Ubuntu 16.04, I tried to install MySQL ODBC as per the official documentation at https://help.ubuntu.com/community/ODBC:
I can see this is getting off to a great start!
Searching the package repository for ODBC hasn't been particularly helpful either. This is a very important part of any modern Linux system! Where did it go?!
PS: Updating the documentation at help.ubuntu.com would be nice too!
Edited to add: Also, it seems that the driver file libmyodbc.so doesn't exist on this version of Ubuntu.
Download directly from dev.mysql.com: https://dev.mysql.com/downloads/connector/odbc/
Select Ubuntu 16.04 64 bit or 32 bit (probably 64 bit), download the TAR ball, then copy the file libmyodbc5a.so
to /usr/lib/x86_64-linux-gnu/odbc/
then, create /etc/odbcinst.ini
and /etc/odbc.ini
Note that the username tag is User (and not username as seen in some examples) and the socket is under /var/run
and not under /var/lib
then worked for me
- Ubuntu配置odbc
- 发布时间:2018-01-19 来源:网络 上传者:用户
关键字:配置发表文章 - 摘要:1、修改数据源vi/etc/apt/source.list添加debhttp://cz.archive.ubuntu.com/ubuntulucidmainuniverse保存sudoapt-getupdate2、安装unixODBCsudoapt-getinstallunixODBC注:没有上一步,会提示没有unixODBC软件包3、安装数据库sudoapt-getinstallmysql-servermysql-client4、安装mysql的odbc驱动apt-geti
- 1、修改数据源
vi /etc/apt/source.list
添加 deb http://cz.archive.ubuntu.com/ubuntu lucid main universe
保存
sudo apt-get update
- 2、安装unixODBC
sudo apt-get install unixODBC
注:没有上一步,会提示没有unixODBC软件包
- 3、安装数据库
sudo apt-get install mysql-server mysql-client
- 4、安装mysql的odbc驱动
apt-get install libmyodbc
- 5、配置(/etc/odbcinst.ini 和 /etc/odbc.ini)
vi /etc/odbcinst.ini
添加
[MySQL]
Description = MySQL
Driver = /usr/lib/i386-linux-gnu/odbc/libmyodbc.so (有可能路径不同,自己搜索一下)
Setup = /usr/lib/i386-linux-gnu/odbc/libodbcmyS.so
FileUsage = 1vi /etc/odbc.ini
[MySql]
Driver = MySQL(与配置的一致)
Description = MySQL ODBC 3.51 Driver DSN
Server = localhost
Port = 3306
User = root
Password = root
Database = test(需要自己创建数据库test)
Option = 3
Socket =
- 6、测试
isql MySql root root
打印出:+—————————————+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+—————————————+