[英]I'm getting "No such file or directory: 'psql'" when I try to run a psql command with Python subprocess. What am I doing wrong?
[英]What am I logging in as when I type psql in the command line?
如果我只是鍵入psql
我會在命令行中打開程序,對嗎? 我以誰身份登錄? 當我選擇隨后要進入的數據庫時,我會說那個用戶嗎?
類型
select user;
知道你是誰
c:\Program Files\PostgreSQL\9.5\pg_env.bat
C:\Program Files\PostgreSQL\9.5>psql
Password:
psql (9.5.1)
postgres=# select user;
current_user
--------------
postgres
(1 row)
在此示例中,用戶名是postgres,因為pg_env.bat
設置PGUSER=postgres
如果鍵入psql
postgres,請嘗試使用與OS用戶相同的名稱進行連接。
Welcome to Ubuntu 16.04.2 LTS (GNU/Linux 4.9.36-x86_64-linode85 x86_64)
Last login: Sat Sep 16 11:02:09 2017
tute@codenautas-server:~$ whoami
tute
tute@codenautas-server:~$ psql
psql: FATAL: role "tute" does not exist
tute@codenautas-server:~$
您可以使用enviroment變量對其進行更改或將其更改:
sudo -u postgres psql
# select user;
current_user
--------------
postgres
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.