Created
November 28, 2018 07:45
-
-
Save emprit1988/503d52066bc64311e313a285aaef7616 to your computer and use it in GitHub Desktop.
Remove postgres and install Postgres 10 (Ubuntu 14.04)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Step1: Take dump of all your databases | |
pg_dumpall > outputfile | |
Step2: Uninstall Postgres | |
dpkg -l | grep postgres | |
Step3: Get list of all postgres related packages from Step 2 and form purge command | |
sudo apt-get --purge remove postgresql postgresql-8.3 postgresql-client postgresql-client-8.3 postgresql-client-common postgresql-common postgresql-contrib postgresql-contrib-8.3 | |
Step4: Remove all data directories | |
sudo rm -rf /var/lib/postgresql/ | |
sudo rm -rf /var/log/postgresql/ | |
sudo rm -rf /etc/postgresql/ | |
Step5: Follow the instruction to install Postgres10 | |
https://www.postgresql.org/download/linux/ubuntu/ | |
Step6: If it results with following error, it means PG service is trying to start using systemctl. Generally ubuntu 14 doesnt use systemctl | |
Failed to issue method call: Unit [email protected] failed to load: No such file or directory. See system logs and 'systemctl status [email protected]' for details. | |
Step7: Tweak the startup scripts to skip systemctl (--skip-systemctl-redirect) | |
Goto: /usr/share/postgresql-common/init.d-functions | |
Change this | |
if [ "$1" = "stop" ] || [ "$1" = "restart" ]; then | |
ERRMSG=$(pg_ctlcluster --force "$2" "$name" $1 2>&1) | |
else | |
ERRMSG=$(pg_ctlcluster "$2" "$name" $1 2>&1) | |
fi | |
to | |
if [ "$1" = "stop" ] || [ "$1" = "restart" ]; then | |
ERRMSG=$(pg_ctlcluster --skip-systemctl-redirect --force "$2" "$name" $1 2>&1) | |
else | |
ERRMSG=$(pg_ctlcluster --skip-systemctl-redirect "$2" "$name" $1 2>&1) | |
fi | |
Step8: Restart postgres service | |
sudo service postgresql restart | |
Step9: Create postgres user and configure it for the first time | |
i) sudo –u postgres psql postgres | |
ii) \password postgres | |
iii) Edit /etc/postgresql/9.3/main/pg_hba.conf and change: | |
#Database administrative login by Unix domain socket | |
local all postgres peer | |
To: | |
#Database administrative login by Unix domain socket | |
local all postgres md5 | |
Step10: Restart postgres service | |
sudo service postgresql restart | |
Step11: Restore dump | |
psql -U postgres < /home/user/bkup1/outfile | |
References: | |
https://askubuntu.com/questions/1000631/unable-to-install-postgresql-10-on-ubuntu | |
https://ubuntuforums.org/showthread.php?t=2277582 | |
https://askubuntu.com/questions/32730/how-to-remove-postgres-from-my-installation |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment