标签: postgresql-13

基于 ARM 的 M1 Mac w/Big Sur 上的 Postgres 错误

自从我买了一台新的基于 ARM 的 M1 MacBook Pro,我就一直遇到严重且一致的 PostgreSQL 问题 (psql 13.1)。无论我使用 Rails 服务器还是 Foreman,我都会在浏览器和终端中收到错误,例如PG::InternalError: ERROR: could not read block 15 in file "base/147456/148555": Bad addressorPG::Error (invalid encoding name: unicode)Error during failsafe response: PG::UnableToSend: no connection to the server。奇怪的是,我经常可以反复刷新浏览器以使其正常工作(直到它们不可避免地再次出现)。

我知道与基于 ARM 的 M1 Mac 相关的所有配置挑战,这就是为什么我以多种方式多次卸载并重新安装从 Homebrew 到 Postgres 的所有内容(使用 Rosetta,不使用 Rosetta,使用arch -x86_64 brew命令,使用 Postgres 应用程序)而不是 Homebrew 安装)。我在随机留言板上遇到了其他几个人,他们遇到了同样的问题(也在新的 Mac 上)并且没有任何运气,这就是为什么我不愿意相信这是一个驱动器损坏问题。(我也多次运行磁盘工具急救检查;它说一切正常,但我不知道它有多可靠。)

我正在使用thoughtbot parity 将我的开发环境数据库与当前生产中的数据库同步。当我运行时development restore production,我在终端中得到数百行,看起来像下面的输出(这是在下载完成后立即但在继续创建默认值、处理数据、序列集等之前)。我相信这是问题的根源,但我不确定解决方案是什么:

pg_restore: dropping TABLE [table name1]
pg_restore: from TOC …
Run Code Online (Sandbox Code Playgroud)

pg-restore thoughtbot macos-big-sur postgresql-13 apple-silicon

24
推荐指数
2
解决办法
7436
查看次数

由于不支持身份验证类型 10,无法连接到 Postgres DB

我最近尝试了 Postgres。将其安装在本地(PostgreSQL 13.0)上。创建了一个 Maven 项目并使用了 Spring Data JPA,效果很好。而当我尝试使用 Gradle 项目时,我无法连接到数据库并不断收到以下错误。

org.postgresql.util.PSQLException:不支持身份验证类型 10。检查您是否已将 pg_hba.conf 文件配置为包含客户端的 IP 地址或子网,并且它正在使用驱动程序支持的身份验证方案。在 org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:614) ~[postgresql-42.1.4.jar:42.1.4] 在 org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java: 222) ~[postgresql-42.1.4.jar:42.1.4] 在 org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49) ~[postgresql-42.1.4.jar:42.1.4] 在 org. postgresql.jdbc.PgConnection.(PgConnection.java:194) ~[postgresql-42.1.4.jar:42.1.4] at org.postgresql.Driver.makeConnection(Driver.java:450) ~[postgresql-42.1.4. jar:42.1.4] 在 org.postgresql.Driver。

我也尝试使用 JDBCTemplate。不起作用

修改了参考这篇文章的 pg_hba.cfg 文件- 不起作用

使用已弃用的 Lib - 也不起作用。

请建议我解决这个问题。

我的代码和配置:

    @Configuration
    public class DataSourceConfig {
    
        
        @Bean
        public DriverManagerDataSource getDataSource() {
            DriverManagerDataSource dataSourceBuilder = new DriverManagerDataSource();
            dataSourceBuilder.setDriverClassName("org.postgresql.Driver");
            dataSourceBuilder.setUrl("jdbc:postgresql://localhost:5432/postgres");
            dataSourceBuilder.setUsername("postgres");
            dataSourceBuilder.setPassword("root");
            return dataSourceBuilder;
        }
        
    }



@Component
public class CustomerOrderJDBCTemplate implements CustomerOrderDao{
    
    private DataSource …
Run Code Online (Sandbox Code Playgroud)

java postgresql gradle spring-boot postgresql-13

17
推荐指数
6
解决办法
3万
查看次数

收到错误:未知的authenticationOk消息typeMessage {名称:'authenticationOk',长度:23}

我已经在Windows 10中安装了Postgres 13。在项目的环境文件中配置了所有正确的凭据。该项目使用以下依赖项,并在 ubuntu 中创建。

"pg": "^7.4.3",
"pg-hstore": "^2.3.2",
"sequelize": "4.38.0",
"sequelize-cli": "^6.2.0"
Run Code Online (Sandbox Code Playgroud)

我正在尝试在 Windows 中设置它。并且在 Windows 10 中出现以下错误。

Error: Unknown authenticationOk message typeMessage { name: 'authenticationOk', length: 23 }
Run Code Online (Sandbox Code Playgroud)

当我点击 npx sequelize db:migrate 终端来迁移数据库中的表时。

postgresql node.js sequelize.js sequelize-cli postgresql-13

10
推荐指数
1
解决办法
9158
查看次数

如何在没有锁的情况下并行复制到一个 PostgreSQL 表中?

正如我在 中看到的,一次pg_stat_activiry只有一个命令执行。COPY正如我在专栏中看到的那样,其他查询处于锁定状态wait_event_type

一次只有一个活动查询

如何COPY mytable FROM STDIN在不锁定表的情况下并行运行多个?

附:mytable是TimescaleDB 2.5.0的超表。

UPD

CREATE TABLE "public"."mytable" (
    "q_time" timestamp,
    "symbol_id" int,
    "o" decimal(24,12),
    "c" decimal(24,12),
    "h" decimal(24,12),
    "l" decimal(24,12),
    "v" bigint,
    CONSTRAINT mytable_ts_pkey PRIMARY KEY (symbol_id, "q_time")
);

SELECT create_hypertable('mytable', 'q_time', 'symbol_id', 1,
  create_default_indexes => false, 
  chunk_time_interval => '7 days'::interval);

Run Code Online (Sandbox Code Playgroud)

UPD2

我并行运行下一个命令:

out, err := exec.Command("bash", "-c", "cat file01.gz | gunzip | psql -d db -U user -c "\copy mytable from stdin HEADER DELIMITER …
Run Code Online (Sandbox Code Playgroud)

postgresql parallel-processing timescaledb postgresql-13

10
推荐指数
0
解决办法
2546
查看次数

快速获取连接表中最新相关行的顶行

有两个表conversationsmessages,我想获取对话及其最新消息的内容。

conversations- id(主键)、名称、创建时间

messages- id、内容、created_at、conversation_id

目前我们正在运行此查询来获取所需的数据

SELECT
    conversations.id,
    m.content AS last_message_content,
    m.created_at AS last_message_at
FROM
    conversations
INNER JOIN messages m ON conversations.id = m.conversation_id
                     AND m.id = (
    SELECT
        id
    FROM
        messages _m
    WHERE
        m.conversation_id = _m.conversation_id
    ORDER BY
        created_at DESC
    LIMIT 1)
ORDER BY
    last_message_at DESC
LIMIT 15
OFFSET 0
Run Code Online (Sandbox Code Playgroud)

上面的查询返回有效数据,但其性能随着行数的增加而降低。有没有其他方法可以提高性能来编写此查询?例如附加小提琴。

http://sqlfiddle.com/#!17/2decb/2

还尝试了已删除答案之一中的建议:

SELECT DISTINCT ON (c.id)
       c.id,
       m.content AS last_message_content,
       m.created_at AS last_message_at
  FROM conversations AS c
 INNER JOIN messages AS m …
Run Code Online (Sandbox Code Playgroud)

sql postgresql greatest-n-per-group postgresql-performance postgresql-13

10
推荐指数
2
解决办法
373
查看次数

postgres C:: 使用 Windows 时权限被拒绝

我使用的是 Windows 10

当我在 PSQL CMD 中运行时,我有一个 PostgreSQL 文件

\i 文件名路径

postgres=# \i C:\Users\Asus\Desktop\Projects\Movies\solution.sql
C:: Permission denied
Run Code Online (Sandbox Code Playgroud)

我收到“权限被拒绝”的消息

C:: 权限被拒绝

有没有解决的办法?或者我怎样才能获得许可?

windows postgresql psql postgresql-13

9
推荐指数
1
解决办法
8664
查看次数

postgresql-client-13 :取决于:libpq5 (>= 13~beta2) 但要安装 12.3-1.pgdg18.04+1

我想尝试新的 PostgreSQL 并按照说明进行操作。但是安装失败:

$ sudo apt install postgresql-client-13
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 postgresql-client-13 : Depends: libpq5 (>= …
Run Code Online (Sandbox Code Playgroud)

postgresql linux-mint-19 postgresql-13

8
推荐指数
2
解决办法
3529
查看次数

PostgreSQL 将密码加密从 SCRAM 降级为 md5

我需要将用户postgres的密码加密从scram-sha-265降级为md5

我尝试修改pg_hba.confpostgresql.conf文件,将密码加密从scram-sha-256更改为md5,但之后我无法连接到数据库。

我正在使用 PostgreSQL 13 和 PgAdmin 4 v5。

感谢您的任何帮助和建议!

PS:我必须这样做,因为 RStudio 无法通过 scram 身份验证管理连接。

postgresql md5 password-encryption psql postgresql-13

8
推荐指数
1
解决办法
1万
查看次数

如何在 PostgreSQL 中列出表的所有索引及其相应的大小?

我可以查看表中所有索引的总大小

SELECT pg_size_pretty (pg_indexes_size('table_name'));

以及特定索引的大小:

select pg_size_pretty(pg_relation_size('index_name'));,

但我想分别检索一个包含表的每个索引的大小信息的列表(索引大小的列表及其所属的相应索引名称)

postgresql indexing postgresql-12 postgresql-13

8
推荐指数
2
解决办法
7125
查看次数

将 postgresql 本地复制到远程数据库(均带有密码)-错误:无法识别选项“locale”

使用 Postgres 12 / Windows 10。

尝试使用以下命令将远程数据库复制到 localhost:

pg_dump -C -h remotehost -p 5432 -U postgres remotedb | psql -h localhost -p 5432 -U postgres localdb

CMD 请求密码 2x。

Password for user postgres: Password:

我先输入 localhost,按 ENTER,然后输入 remotehost 并再次按 ENTER。

这是我得到的错误回报:

SET
SET
SET
SET
SET
 set_config
------------

(1 row)

SET
SET
SET
SET
ERROR:  option "locale" not recognized
LINE 1: ...ting" WITH TEMPLATE = template0 ENCODING = 'UTF8' LOCALE = '...
                                                             ^
ERROR:  database "remotedb" does not exist
\connect: …
Run Code Online (Sandbox Code Playgroud)

postgresql pg-dump psql postgresql-12 postgresql-13

7
推荐指数
2
解决办法
1470
查看次数