[英]Azure PostgreSQL Server Service Collation Create Error
I'm trying to import my current existing database to postgre instance that is running on Azure PostgreSQL Server我正在尝试将我当前的现有数据库导入到 Azure PostgreSQL 服务器上运行的 postgre 实例
I already configured my azure postgresql server parameters to use encoding as UTF8 (I'm not sure that it's applying without restart but even if i don't have option to restart it)我已经将我的 azure postgresql 服务器参数配置为使用 UTF8 编码(我不确定它是否在不重启的情况下应用,但即使我没有重启它的选项)
I'm trying to do this action with this command:我正在尝试使用以下命令执行此操作:
sudo -u postgres pg_dump --encoding="UTF-8" --no-owner DBNAME | psql --host=xxx.postgres.database.azure.com --port=5432 --username=xxx@yyy --dbname=DBNAME
However it's getting an error something like this:但是,它收到了这样的错误:
ERROR: could not create locale "en_US.utf8": No error
错误:无法创建区域设置“en_US.utf8”:没有错误
I dive in the process and try to run it with UTF8 (Instead of UTF-8) and other options but it's got same error everytime.我深入这个过程并尝试使用 UTF8(而不是 UTF-8)和其他选项运行它,但每次都会出现相同的错误。
I created a dump file to check the contents and the line that is generating this error is:我创建了一个转储文件来检查内容,生成此错误的行是:
CREATE COLLATION "en_US.utf8" (lc_collate = 'en_US.utf8', lc_ctype = 'en_US.utf8');
This is causing that error.这是导致该错误的原因。 I tried to execute it manually on Azure postgre instance and i got same error too.
我尝试在 Azure postgre 实例上手动执行它,我也遇到了同样的错误。
By the way I already created that DATABASE from console by using this SQL:顺便说一下,我已经使用以下 SQL 从控制台创建了该数据库:
create database "DBNAME" with owner=xxx encoding='UTF-8' template template0;
Also i tried other options to create and import but non of them work.我也尝试了其他选项来创建和导入,但它们都不起作用。
Can someone help me?有人能帮我吗?
I resolved my issue with this command:我用这个命令解决了我的问题:
sudo -u postgres pg_dump -Fp —no-owner DBNAME |sed “/COLLATE/s/en_US.utf8/English_United States.1252/ig”|sed "/CREATE COLLATION/s/en_US.utf8/English_United States.1252/ig"|psql --host=aaa.postgres.database.azure.com --port=5432 --username=xxx@yyy --dbname=DBNAME
The issue is coming from the server OS differences.问题来自服务器操作系统差异。 My current PostgreSQL server is using Ubuntu but Azure PostgreSQL Server is using windows so the collate names are little bit different.
我当前的 PostgreSQL 服务器使用的是 Ubuntu,但 Azure PostgreSQL 服务器使用的是 Windows,因此整理名称略有不同。
CREATE COLLATION
creates a operating system independent name that can be used to refer to OS locales (in queries etc). CREATE COLLATION
创建一个独立于操作系统的名称,可用于引用操作系统区域设置(在查询等中)。
Here lc_collate = 'en_US.utf8'
and lc_ctype = 'en_US.utf8'
refer to Linux operating system locales, which are named differently on Windows, which Azure PostgreSQL uses (and they're different on MacOS, too).这里
lc_collate = 'en_US.utf8'
和lc_ctype = 'en_US.utf8'
指的是 Linux 操作系统区域设置,它们在 Windows 上的命名不同,Azure PostgreSQL 使用这些区域设置(它们在 MacOS 上也不同)。
On Windows, this should work在 Windows 上,这应该可以工作
CREATE COLLATION "en_US.utf8" (lc_collate = 'English_United States', lc_ctype = 'English_United States');
And on MacOS,而在 MacOS 上,
CREATE COLLATION "en_US.utf8" (lc_collate = 'en_US', lc_ctype = 'en_US');
But most of the time, you don't want to create your own collations with CREATE COLLATION
, but can just use the pre-included collations in PostgreSQL.但是大多数时候,您不想使用
CREATE COLLATION
创建自己的排序规则,而可以只使用 PostgreSQL 中预先包含的排序规则。 And normally a dump created with pg_dump
does not include any CREATE COLLATION
statements, since you haven't created any yourself.通常,使用
pg_dump
创建的转储不包含任何CREATE COLLATION
语句,因为您没有自己创建任何语句。
Unless you're doing something special with collations, is it possible to remove those schema-specific collations, so they won't get included in the dump?除非您对排序规则进行特殊处理,否则是否可以删除那些特定于架构的排序规则,以便它们不会包含在转储中?
We've previously run into this same issue running Atlassian's Confluence.我们之前在运行 Atlassian 的 Confluence 时遇到过同样的问题。 The application would not start due to an incorrect collation type.
由于不正确的整理类型,应用程序不会启动。 We were able to resolve by assigning
English_United States.1252
directly.我们可以通过直接分配
English_United States.1252
来解决。
CREATE DATABASE db
WITH ENCODING 'UTF8'
LC_COLLATE 'English_United States.1252'
LC_CTYPE 'English_United States.1252'
TEMPLATE template0
OWNER conf;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.