-
-
Save jdmedeiros/48fdd389d296e1bb187b4026d51271d8 to your computer and use it in GitHub Desktop.
PostgreSQL install and setup
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
:'SET PASSWORD | |
sudo -i -u postgres | |
psql | |
\password postgres | |
' | |
# RHEL / CentOS 8 | |
# https://www.postgresql.org/download/linux/redhat/ | |
# https://www.postgresql.org/docs/current/runtime.html | |
dnf list installed |grep postgresql | |
dnf install https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm | |
dnf install postgresql12 postgresql12-server | |
# Fedora 31 | |
dnf install https://download.postgresql.org/pub/repos/yum/reporpms/F-31-x86_64/pgdg-fedora-repo-latest.noarch.rpm | |
dnf install postgresql12 postgresql12-server | |
# RHEL / CentOS 7 | |
#yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm | |
#yum install postgresql12 postgresql12-server | |
echo 'LC_ALL="ru_RU.UTF-8"' >> /etc/locale.conf | |
#PGDATA='/srv/data/12/data' | |
#PGSETUP_INITDB_OPTIONS="-D ${PGDATA}" | |
/usr/pgsql-12/bin/postgresql-12-setup initdb | |
systemctl enable postgresql-12 | |
systemctl start postgresql-12 | |
sed -i 's/^host\s*all\s*all\s*127\.0\.0\.1\/32\s*ident/host all all 127.0.0.1\/32 md5/' /var/lib/pgsql/12/data/pg_hba.conf | |
#msg "Set PGDATA to "${PGDATA} | |
#sed -i "s~^Environment=PGDATA=.*~Environment=PGDATA=\${PGDATA}/~" /usr/lib/systemd/system/postgresql-12.service | |
#systemctl daemon-reload | |
# ------------------------------- | |
# Debian 10 | |
# https://www.postgresql.org/download/linux/debian/ | |
# https://computingforgeeks.com/install-postgresql-12-on-debian/ | |
# ------------------------------- | |
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ buster-pgdg main" >> /etc/apt/sources.list.d/pgdg.list' | |
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - | |
sudo apt-get update | |
sudo apt -y install postgresql-12 postgresql-client-12 | |
sudo systemctl status postgresql | |
sudo systemctl enable postgresql | |
sudo systemctl stop postgresql | |
# ------------------------------- | |
# Ubuntu 18.04 LTS | |
# https://www.postgresql.org/download/linux/ubuntu/ | |
# ------------------------------- | |
# nano /etc/apt/sources.list.d/pgdg.list | |
deb http://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main | |
apt-cache policy postgresql-12 | |
# ru_RU.UTF-8: | |
echo 'LC_COLLATE="ru_RU.UTF-8"' >> /etc/locale.conf | |
# reboot! | |
# Plan B: | |
# su - postgres -c "/usr/lib/postgresql/12/bin/initdb --pgdata=/var/lib/postgresql/12/main --locale=ru_RU.UTF-8" | |
apt install postgresql-12 postgresql-contrib | |
sudo systemctl status postgresql.service | |
sudo systemctl start postgresql.service | |
sudo -i -u postgres | |
psql --version | |
psql -l | |
psql | |
\password postgres |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment