无法将 postgresql 数据库复制到新服务器,出现错误 [无法识别的参数“row_security”]
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35447834/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Cannot copy postgresql database to new server with error [unrecognized parameter "row_security"]
提问by Philip Young
I'm novice in PostgreSQL. I've succesfully created database, set "philipyoung"—my ID as super user, and use the command below, to copy local database to new server in elephantsql.
我是 PostgreSQL 的新手。我已经成功创建了数据库,将“philipyoung”——我的 ID 设置为超级用户,并使用下面的命令,将本地数据库复制到大象 SQL 中的新服务器。
pg_dump -C -h localhost -U localuser dbname | psql -h remotehost -U remoteuser dbname
and then the error below happens
然后发生下面的错误
SET
SET
SET
SET
SET
ERROR: unrecognized configuration parameter "row_security"
ERROR: permission denied to create database
ERROR: role "philipyoung" does not exist
FATAL: no pg_hba.conf entry for host "xxx.xxx.xxx.xx", user "xxxx", database "xxxx", SSL on
any help would be appreciated
任何帮助,将不胜感激
采纳答案by Richard Huxton
The "row_security" error is probably because you have a newer version of PostgreSQL locally than on the remote end. That's not a problem unless you are using that feature.
“row_security”错误可能是因为您在本地拥有比远程端更新的 PostgreSQL 版本。除非您使用该功能,否则这不是问题。
The "permission denied" and "user X does not exist" errors are why it is failing. You are trying to restore the database as a user that does not have permission to create a database on the remote server. Then, it can't find the relevant user, and then you haven't set up that user for remote access either.
“权限被拒绝”和“用户 X 不存在”错误是它失败的原因。您正在尝试以无权在远程服务器上创建数据库的用户身份还原数据库。然后,它找不到相关用户,然后您也没有设置该用户进行远程访问。
Users are shared between databases and not copied with them.
用户在数据库之间共享,而不是与它们一起复制。
So - you want to do something like:
所以 - 你想做这样的事情:
- Log in as "postgres" on the remote server and "CREATE USER x ..."
- Restore the database as user "postgres" on the remote server and it should be able to set the ownership to the user you want.
- 在远程服务器上以“postgres”身份登录并使用“CREATE USER x ...”
- 将数据库恢复为远程服务器上的用户“postgres”,它应该能够将所有权设置为您想要的用户。
If you do not want to grant remote access to your database you may want to either create a ssh tunnel (lots of examples on the internet) or dump to a file (use "-Fc" for the custom, compressed format) and copy the dump to the remote machine first.
如果您不想授予对数据库的远程访问权限,您可能需要创建 ssh 隧道(互联网上有很多示例)或转储到文件(使用“-Fc”作为自定义压缩格式)并复制首先转储到远程机器。
If possible, try to run the same version of PostgreSQL on both servers. It makes things easier if they do need to communicate.
如果可能,请尝试在两台服务器上运行相同版本的 PostgreSQL。如果他们确实需要沟通,这会让事情变得更容易。