近期要在 Ubuntu 上升級 postgresql 發現一般的更新方法是行不通的,比如說 apt-get update; apt-get upgrade postgresql。

目前找到的解法是需要去更新 apt-get 的來源列表,以下是指令串

vim /etc/apt/sources.list.d/postgresql.list # new or edit
deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main 9.5 # you can change the version number as you want

設定完後,即可開始認證並更新整個 postgresql 的版本庫

wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
apt-get update
apt-get install postgresql-9.5