1. 程式人生 > >Linux 下使用Postgre中的命令,要使用postgres這個使用者

Linux 下使用Postgre中的命令,要使用postgres這個使用者

問題:

使用root使用者連線linux執行psql命令(比如 psql -l 命令)

報錯: rote "root" dose not exist

解決方案:

切換到psql下的使用者  命令是:su postgres

 使用者切換之後,便可以執行下面的命令了

psql -l 檢視使用者資訊

例項:

這次需要執行的是,匯出部分資料

psql saison -c 'select user_id, user_name from user order by 1,2'  user_list.txt -A -F, -t 

總結

雖然root是liunx中的超級使用者,但是對於postgre tomcat 等一些程式

它們有自己的使用者,這時,我們就需要切換到該程式相對應的使用者下

su postgres  (su switch user)