Setup Mysql Foreign Data Wrapper in Postgresql

蹲街弑〆低调 提交于 2019-12-10 10:16:19

问题


Could somebody help me understand how I would go about setting up postgresql's mysql_fdw? I'm looking at https://github.com/EnterpriseDB/mysql_fdw, and I not sure what the first step is.


回答1:


You linked to the ODBC foreign data wrapper odbc_fdw. You can use it for MySQL, but if you just want MySQL you should use mysql_fdw instead. That way you don't have to mess with ODBC.

Handily, the README for mysql_fdw contains detailed instructions for installation and configuration, so you should be fine setting it up; I won't duplicate those instructions here.




回答2:


I was able to do it the following way.

Installing the package:

sudo apt-get install postgresql-9.5-mysql-fdw

Adds the extension in the Database:

CREATE EXTENSION mysql_fdw;

Add the mysql server to postgresql:

CREATE SERVER mysql_server FOREIGN DATA WRAPPER mysql_fdw OPTIONS (host 'localhost', port '3306');

Create a user to access the database:

CREATE USER MAPPING FOR postgres SERVER mysql_server OPTIONS (username 'root', password 'passwordToConnect');

Import a Schema table from another server

IMPORT FOREIGN SCHEMA mySchema LIMIT TO (tableName) FROM SERVER mysql_server INTO public;

Imports all Schema tables from another server

IMPORT FOREIGN SCHEMA mySchema FROM SERVER mysql_server INTO public;

I hope I have helped.



来源:https://stackoverflow.com/questions/24683035/setup-mysql-foreign-data-wrapper-in-postgresql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!