1、安装
下载地址:https://github.com/EnterpriseDB/mysql_fdw
修改环境变量:
export MYSQLHOME=/usr/local/mysql
export PGHOME=/home/pg12/pgsql12.4
export LD_LIBRARY_PATH=$PGHOME/lib:$MYSQLHOME/lib:/lib64:/usr/lib64:/usr/local/lib64:/lib:/usr/lib:/usr/local/lib
export PATH=$PGHOME/bin:$MYSQLHOME/bin:$PATH:.
解压安装:
[root@oracle ~]# unzip mysql_fdw-master.zip
[root@oracle ~]# cd mysql_fdw-master
[root@oracle ~]# make USE_PGXS=1
[root@oracle ~]# make USE_PGXS=1 install
在pg中创建mysql_fdw插件:
bill=# create extension mysql_fdw ;
CREATE EXTENSION
这一步可能会出现如下报错:
bill=# create extension mysql_fdw ;
ERROR: failed to load the mysql query:
libmysqlclient.so: cannot open shared object file: No such file or directory
HINT: export LD_LIBRARY_PATH to locate the library
如果是源码编译安装的MySQL可能会出现这个问题,需要设置LD_LIBRARY_PATH,设置完之后再重新启动pg数据库。
2、使用
mysql中测试表:
mysql> select * from t_mysql;
+------+---------------+
| id | info |
+------+---------------+
| 1 | this