首先更新一下源:sql
sudo apt-get update
若是你不知道Postgresql具體的包的名稱,可使用一下語句進行查找:數據庫
apt-cache search ^Postgresql
使用上述搜索,能夠查到當前可安裝的Postgresql版本,使用apt-get進行安裝:post
sudo apt-get install postgresql-9.3
使用apt-get install安裝時,會自動安裝好其依賴的各個庫(安裝過程會提示,選Y便可)。spa
安裝完成以後運行psql,會提示以下錯誤:postgresql
bob@localhost:~$ psql psql: FATAL: role "bob" does not exist
出現這個提示,須要切換到數據庫系統默認的postgres用戶下便可:code
sudo -u postgres -i