PG connect 字符串错误

PostgreSQL: Documentation: 17: 32.1. Database Connection Control Functions 使用 pg mcp 连接数据库时遇到的问题 贴出的命令中密码改了 显示已折叠代码(16 行) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 (MCBot_py311) yangr@172-16-99-32-Dev:/data/yangr/gitRepos/LG_rag_hw$ npx -y @modelcontextprotocol/server-postgres "postgresql://lmi:abc#[email protected]:5432/lmi" node:internal/url:818 href = bindingUrl.parse(input, base, true); ^ TypeError: Invalid URL at new URL (node:internal/url:818:25) at file:///home/yangr/.npm/_npx/cd1ce99963b5e8b1/node_modules/@modelcontextprotocol/server-postgres/dist/index.js:21:25 at ModuleJob.run (node:internal/modules/esm/module_job:271:25) at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:547:26) at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:116:5) { code: 'ERR_INVALID_URL', input: 'postgresql://lmi:abc#[email protected]:5432/lmi' } Node.js v22.12.0 问了 G 老师,遇到 TypeError: Invalid URL 错误,通常是因为你的连接 URI 中包含了 未经转义 的 “#” 字符——这在 URL 语法中会被误解析为fragment 分隔符,导致 Node.js 的 URL 构造器无效 。 ...

August 4, 2025 · 1 min · 143 words · Updated: August 13, 2025 · Ray