问题
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.
- Backup your data. You will dropping the database, so no games!
sudo -u postgres pg_dumpall > all.sql
- 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