wps中可以引入ODBC的数据源,方便做后续数据分析
步骤
sudo apt install unixodbc
sudo apt install unixodbc-dev
下载MySQL ODBC driver
https://dev.mysql.com/downloads/connector/odbc/
解压后把bin和lib中的文件 copy到对应的目录
sudo tar zxvf mysql-connector-odbc-8.0.15-linux-ubuntu18.04-x86-64bit.tar.gz
cd mysql-connector-odbc-8.0.15-linux-ubuntu18.04-x86-64bit/
sudo cp bin/* /usr/local/bin
sudo cp lib/* /usr/local/lib
// Registers the Unicode driver:
sudo myodbc-installer -a -d -n "MySQL ODBC 8.0 Driver" -t "Driver=/usr/local/lib/libmyodbc8w.so"
// Registers the ANSI driver
sudo myodbc-installer -a -d -n "MySQL ODBC 8.0" -t "Driver=/usr/local/lib/libmyodbc8a.so"
可以发现 /etc/odbcinst.ini 出现了下面的内容
验证是否安装成功
myodbc-installer -d -l
设置ODBC 参数
sudo vi /etc/odbc.ini
增加以下内容
[mysql]
Description = Data source MySQL
Driver = MySQL ODBC 8.0 Driver
Server = 192.168.1.80
Host = 192.168.1.80
Database = test
Port = 3306
User = user1
Password = 123456
一般是通过uncode 方式连接,Driver 必须是MySQL ODBC 8.0 Driver ,
其他参数按mysql server 的设置。Database 选择已经建立好的数据库。
测试连接
isql mysql
sjzx@sjzx:~/dev$ isql mysql
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL> select * from test limit 2;
+---------------------------------------------------+-----------+
| name1 | age |
+---------------------------------------------------+-----------+
| xie | 20 |
| zhang | 22 |
+---------------------------------------------------+-----------+
SQLRowCount returns 2
2 rows fetched
参考文章
https://blog.csdn.net/seakingx/article/details/87879164
https://cdn.cdata.com/help/RVF/synch/default.htm
https://cdn.cdata.com/help/RVB/odbc/pg_connectionodbclinux.htm