gpt4 book ai didi

postgresql - Prisma 无法连接到 postgresql

转载 作者:行者123 更新时间:2023-12-04 11:55:16 25 4
gpt4 key购买 nike

我曾多次尝试将 Prisma 与 postgreSQL 连接起来。
Prisma 显示此错误消息:“错误:未定义:“postgresql://postgres:password@localhost:5432/linker”中的无效端口号)”。
-错误
enter image description here
-棱镜/.env

DATABASE_URL=postgresql://postgres:password@localhost:5432/linker
-schema.prisma
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
所以,首先,我检查了端口号是否正确,5432 是否正确,因为我使用了默认端口号。我还检查了 postgresql.conf 文件,该文件设置为 "listen_address="*"", "port=5432"。
enter image description here
我进入 pgAdmin4 并查看服务器的属性。如下图所示,端口号为 5432,用户名设置为“postgres”。
enter image description here
我不知道为什么prisma无法连接
我错过了什么吗?

最佳答案

用百分比编码替换特殊字符
确保在您的 DATABASE_URL 中在 .env文件中,特殊字符将替换为百分比编码。
例如,如果您的用户名或密码包含 @字符,应替换为其等效的百分比编码,即 %40 .对于 #它是 %23等等。请参阅下面的列表。
百分比编码
以下是常用特殊字符的百分比编码:


特殊字符
百分比编码

!%21#%23$%24%%25&%26'%27(%28)%29*%2A+%2B,%2C/%2F:%3A;%3B=%3D?%3F@%40[%5B]%5Dnewline%0A%0D%0D%0Aspace%20"%22%%25-%2D.%2E<%3C>%3E\%5C^%5E_%5F`%60
{%7B|%7C}%7D~%7E£%C2%A3%E5%86%86

关于postgresql - Prisma 无法连接到 postgresql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63684133/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com