【发布时间】:2014-07-10 17:43:15
【问题描述】:
有人可以帮我理解我将如何设置 postgresql 的 mysql_fdw 吗?我在看https://github.com/EnterpriseDB/mysql_fdw,我不确定第一步是什么。
【问题讨论】:
标签: postgresql foreign-data-wrapper
有人可以帮我理解我将如何设置 postgresql 的 mysql_fdw 吗?我在看https://github.com/EnterpriseDB/mysql_fdw,我不确定第一步是什么。
【问题讨论】:
标签: postgresql foreign-data-wrapper
我可以通过以下方式做到这一点。
安装包:
sudo apt-get install postgresql-9.5-mysql-fdw
在数据库中添加扩展:
CREATE EXTENSION mysql_fdw;
将mysql服务器添加到postgresql:
CREATE SERVER mysql_server FOREIGN DATA WRAPPER mysql_fdw OPTIONS (host 'localhost', port '3306');
创建一个用户来访问数据库:
CREATE USER MAPPING FOR postgres SERVER mysql_server OPTIONS (username 'root', password 'passwordToConnect');
从另一台服务器导入 Schema 表
IMPORT FOREIGN SCHEMA mySchema LIMIT TO (tableName) FROM SERVER mysql_server INTO public;
从其他服务器导入所有 Schema 表
IMPORT FOREIGN SCHEMA mySchema FROM SERVER mysql_server INTO public;
我希望我有所帮助。
【讨论】:
您已链接到 ODBC 外部数据包装器 odbc_fdw。你可以将它用于 MySQL,但如果你只想要 MySQL,你应该use mysql_fdw instead。这样你就不必乱用 ODBC。
方便地,mysql_fdw 的 README 包含安装和配置的详细说明,因此您应该可以设置它;我不会在这里重复这些说明。
【讨论】:
yum install community-mysql-devel 或 yum install mariadb-devel。在 CentOS/RHEL 上,yum install mysql-devel。在 Debian/Ubuntu 上,apt-get install libmysqlclient-dev.
make install - 或者在这种情况下可能是sudo PATH=/usr/pgsql-9.3/bin:$PATH make install 。顺便说一句,以供将来参考,而不是下载单个文件,您可以 git clone 存储库。