Created
July 2, 2013 15:23
-
-
Save brycemcd/5910238 to your computer and use it in GitHub Desktop.
Create a foreign data wrapper in postgres, add perms to user
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- AS ADMIN USER | |
-- create extension, server and fdw | |
CREATE EXTENSION mysql_fdw; | |
CREATE SERVER mysql_svr | |
FOREIGN DATA WRAPPER mysql_fdw | |
OPTIONS (address 'localhost', port '3306'); | |
-- GRANTS | |
GRANT ALL ON FOREIGN DATA WRAPPER mysql_fdw TO some_user; | |
GRANT ALL ON FOREIGN SERVER mysql_svr TO some_user; | |
CREATE USER MAPPING FOR PUBLIC | |
SERVER mysql_svr | |
OPTIONS (username 'dpage', password ''); | |
-- LOG OUT, LOG BACK IN AS NON-ADMIN USER: | |
CREATE FOREIGN TABLE employees ( | |
id integer, | |
name text, | |
address text) | |
SERVER mysql_svr | |
OPTIONS (table 'hr.employees'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment