wps中可以引入ODBC的数据源,方便做后续数据分析

步骤

  1. sudo apt install unixodbc
  2. sudo apt install unixodbc-dev

下载MySQL ODBC driver


https://dev.mysql.com/downloads/connector/odbc/

解压后把bin和lib中的文件 copy到对应的目录

  1. sudo tar zxvf mysql-connector-odbc-8.0.15-linux-ubuntu18.04-x86-64bit.tar.gz
  2. cd mysql-connector-odbc-8.0.15-linux-ubuntu18.04-x86-64bit/
  3. sudo cp bin/* /usr/local/bin
  4. sudo cp lib/* /usr/local/lib
  1. // Registers the Unicode driver:
  2. sudo myodbc-installer -a -d -n "MySQL ODBC 8.0 Driver" -t "Driver=/usr/local/lib/libmyodbc8w.so"
  3. // Registers the ANSI driver
  4. sudo myodbc-installer -a -d -n "MySQL ODBC 8.0" -t "Driver=/usr/local/lib/libmyodbc8a.so"

可以发现 /etc/odbcinst.ini 出现了下面的内容
image.png

验证是否安装成功

  1. myodbc-installer -d -l

设置ODBC 参数


sudo vi /etc/odbc.ini

增加以下内容

  1. [mysql]
  2. Description = Data source MySQL
  3. Driver = MySQL ODBC 8.0 Driver
  4. Server = 192.168.1.80
  5. Host = 192.168.1.80
  6. Database = test
  7. Port = 3306
  8. User = user1
  9. Password = 123456

一般是通过uncode 方式连接,Driver 必须是MySQL ODBC 8.0 Driver ,
其他参数按mysql server 的设置。Database 选择已经建立好的数据库。

测试连接


isql mysql

  1. sjzx@sjzx:~/dev$ isql mysql
  2. +---------------------------------------+
  3. | Connected! |
  4. | |
  5. | sql-statement |
  6. | help [tablename] |
  7. | quit |
  8. | |
  9. +---------------------------------------+
  10. SQL> select * from test limit 2;
  11. +---------------------------------------------------+-----------+
  12. | name1 | age |
  13. +---------------------------------------------------+-----------+
  14. | xie | 20 |
  15. | zhang | 22 |
  16. +---------------------------------------------------+-----------+
  17. SQLRowCount returns 2
  18. 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

image.png