如何启动psql.exe [英] How to start psql.exe

查看:165
本文介绍了如何启动psql.exe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Postgresql(pg)的新手。我知道要与pg交互,必须使用psql.exe。

I'm new to postgresql (pg). I understand that in order to interact with pg, I must use psql.exe.

在我的系统中,我发现psql.exe不是一次,而是两次,为什么? ( C:\程序文件(x86)\pgAdmin 4\v2\运行时\psql.exe C:\Program文件:PostgreSQL\10\bin\psql.exe )。我尝试了两种方法,结果都相同(阴性)。

In my system, I find psql.exe not once, but twice, why? (C:\Program Files (x86)\pgAdmin 4\v2\runtime\psql.exe and C:\Program Files\PostgreSQL\10\bin\psql.exe). I tried both, with identical (negative) results.

与问/答,现在,我不是直接运行psql.exe,而是先打开一个通用(Windows)命令窗口,然后在该通用命令窗口中运行psql.exe。然后输入密码并输入。

In line with Q/A In PostgreSQL why does command line window disappear when I press Enter after entering my password?, I now, instead of running psql.exe directly, I first opened a generic (Windows) command window and then ran psql.exe from within this generic command window; I then entered the password and Enter.

在常规(Windows)命令窗口中,我现在收到消息:

In the generic (Windows) command window, I now got the message:


psql:无法连接到服务器:权限被拒绝(0x0000271D / 10013)

服务器是否在主机 localhost(:: 1)上运行并接受TCP /端口5432上的IP连接?
致命:用户用户的密码身份验证失败

psql: could not connect to server: Permission denied (0x0000271D/10013)
Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? FATAL: password authentication failed for user "User"

这对应于(但未解决)上面引用的问题。此论坛中的其他线程重新pg密码失败,涉及到Linux /过时的密码/更改密码后的新密码。

This corresponds to the problem described (but not resolved) in the Q/A cited above. Other threads in this forum re pg password fails concern Linux / outdated passwords / new passwords after password changes.

在这里的其他线程中提到这个问题是在Windows中,是文件 pgpass.conf 。我找到一个帮助文件libpq-pgpass.html,该文件还说,在我的系统上,没有这样的文件pgpass.conf(除上述html文件外,其他没有 pgpass的文件)。

It's said in other threads here re this question that in Windows, there is a file pgpass.conf. I find a help file libpq-pgpass.html which also says that, while on my system, there is no such file pgpass.conf (or anything else with "pgpass" except for the aforementioned html file).

(W10教授64位英语)

(W10 Prof 64 bit English)

第二种策略:

在开始菜单中,有一个条目 PostgreSQL;在该条目下(可通过Enter输入)有一个子条目 SQL Shell(psql);因此,我尝试了这一点。

Within the StartMenu, there is an entry "PostgreSQL"; under that - available by Enter - there is a sub-entry "SQL Shell (psql)"; so I tried that.

仅从那里获得Windows cmd窗口,带有 psql 10.1和(在[]中,这显然是默认值):

From there only, I get the Windows cmd window, with "psql 10.1" and with (in [] it's obviously the default values):


Server [localhost]: I enter localhost; 
Database [postgres]: I enter postgres; 
Port [5432]: I enter 5432; 
Username [postgres]: I enter postgres; 
Password for user postgres: I enter the password which is "a".


从那里,我在控制台代码页面收到警告与Windows代码页不同,但随后出现psql提示

From there, I get a warning re the Console code page which differs from Windows code page, but I then get the psql prompt

postgres=#

,并且有效。

另一方面,在上述第一个策略下,我仅获得密码:,然后在输入实际密码(即 a)之后,出现致命错误用户 A的密码验证失败。

On the other hand, with the first strategy above, I only get "Password:" and then, after entry of the real password (which is "a"), the "FATAL" error "password authentication failed for user "A"".

在安装时,我创建了一个超级用户 postgres,其密码为 a,而不是用户 A;另一方面,我是Windows管理员(!)帐户的用户 A(我的计算机上没有其他用户,而我本人除外),而我通常会收到cmd提示( C:\Users\A>) ; (但不出所料),如果我从提示符 C:>输入psql.exe的整个路径,则没有不同的结果。

Upon installation, I had created a superuser "postgres" with password "a", not a user "A"; on the other hand, I am user "A" which is my Windows admin (!) account (no other users than myself on my pc) and the cmd prompt I usually get ("C:\Users\A>"); (but as expected,) no different result if I enter the whole path to psql.exe from the prompt "C:>".

所以我的问题现在归结为这:当从开始菜单中触发时,psql.exe正常工作,因为它会问我所有我可以正确回答的问题(如上所述),而从cmd窗口以其完整路径启动时(都尝试了完整路径,当然,它只要求输入密码,然后告诉我,对于某些用户A,该密码是错误的。

So my problem comes now down to this: When triggered from within the start menu, psql.exe works correctly since it asks me all the questions I can then answer correctly (as stated above), while when started with its full path from the cmd window (both full paths tried and enclosed in "" of course), it just asks for the "password" and then tells me that for some "user A", that password is wrong.

从开始菜单中(运行)psql.exe的完整路径是 C:\ProgramData\Microsoft\Windows\Start菜单\程序\PostgreSQL 10\psql.exe ,如果尝试从cmd窗口运行该命令,则会得到(路径)未被识别为内部或外部命令,可操作程序或批处理文件。 SQL Shell(psql).lnk,其属性为:目标: C:\Program Files\PostgreSQL\10\scripts\runpsql。 bat。

Also, the full path to the (functioning) psql.exe from within the start menu is C:\ProgramData\Microsoft\Windows\Start Menu\Programs\PostgreSQL 10\psql.exe, and if I try to run that from with the cmd window, I get "(path) is not recognized as an internal or external command, operable program or batch file.", since in there, it's "SQL Shell (psql).lnk", of which the properties are: "Target: "C:\Program Files\PostgreSQL\10\scripts\runpsql.bat"".

所以这是解决方案,请参见下面的答案。

So this is the solution, see my answer below.

推荐答案

您不需要运行某些psql.exe文件,而是运行C:CProgram Files\PostgreSQL\10\scripts\runpsql.bat文件,例如以编程方式,例如来自AHK:

You don't run some psql.exe file, but the file C:\Program Files\PostgreSQL\10\scripts\runpsql.bat , for example programmatically, e.g. from AHK:

运行, C:\Program Files\PostgreSQL\10\scripts\runpsql.bat

run, "C:\Program Files\PostgreSQL\10\scripts\runpsql.bat"

然后您将获得一个通用的Windows命令窗口,该窗口询问您正确的问题(请参见上文),并在正确回答后为您提供psql命令提示符。

Then you get a generic Windows command window which asks you the right questions (see above) and, when answered correctly, gives you the psql command prompt.

这篇关于如何启动psql.exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆