How to upgrade to PostgreSQL 11 for Ubuntu 18.04?

▼魔方 西西 提交于 2020-06-24 12:14:05

问题


As the title suggests I want to upgrade my postgresql-10 to postgresql-11.

I'm using ubuntu-18.04.


回答1:


You can follow this blog setup Postgresql-11 on Ubuntu. I found it easy and simple.

Add the PostgreSQL package repository on your Ubuntu machine

echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main 11" | sudo tee /etc/apt/sources.list.d/pgsql.list

Add the GPG key of the PostgreSQL package repository:

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

Update APT and install postgresql-11

sudo apt update && sudo apt install postgresql-11



回答2:


Installing Postgres 11 (or, by now, v12) can be done by running:

sudo apt install postgresql-common
sudo sh /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh

This is documented on https://wiki.postgresql.org/wiki/Apt
See there if you wish to run the steps manually.

Once you have installed Postgres, the easiest way to upgrade is with pg_upgradecluster.

  1. Backup your data. You will dropping the database, so no games!
sudo -u postgres pg_dumpall > all.sql
  1. Upgrade.
// Install latest Postgres     
sudo apt-get install -y postgresql // or postgresql-11 for v11

// stop and remove the newly installed cluster. 
// The install sets up a cluster, which needs then to be removed for the upgrade.  
sudo pg_dropcluster 11 main --stop 

// Upgrade the db, takes the OLD version and OLD schema as required arguments
sudo pg_upgradecluster 10 main

// Test. Once you are satoisfied, remove OLD cluster.
sudo pg_dropcluster 10 main



回答3:


Use this command:

sudo apt update && sudo apt install postgresql-11


来源:https://stackoverflow.com/questions/52765873/how-to-upgrade-to-postgresql-11-for-ubuntu-18-04

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!