Skip to content

Instantly share code, notes, and snippets.

@coder4web
Last active November 4, 2022 22:16

Revisions

  1. coder4web renamed this gist Jun 2, 2022. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions postgresql_install.sql → postgresql_install.sh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,8 @@
    :'SET PASSWORD
    sudo -i -u postgres
    psql
    \password postgres
    '

    # RHEL / CentOS 8
    # https://www.postgresql.org/download/linux/redhat/
  2. coder4web revised this gist Jun 2, 2022. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions postgresql_install.sql
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,6 @@
    sudo -i -u postgres
    \password postgres

    # RHEL / CentOS 8
    # https://www.postgresql.org/download/linux/redhat/
    # https://www.postgresql.org/docs/current/runtime.html
  3. coder4web revised this gist Mar 17, 2020. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions postgresql_install.sql
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,7 @@
    # 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

  4. coder4web revised this gist Feb 5, 2020. 1 changed file with 14 additions and 0 deletions.
    14 changes: 14 additions & 0 deletions postgresql_install.sql
    Original file line number Diff line number Diff line change
    @@ -27,6 +27,20 @@ sed -i 's/^host\s*all\s*all\s*127\.0\.0\.1\/32\s*ident/host all a
    #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/
  5. coder4web revised this gist Dec 3, 2019. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion postgresql_install.sql
    Original file line number Diff line number Diff line change
    @@ -37,9 +37,10 @@ deb http://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main
    apt-cache policy postgresql-12

    # ru_RU.UTF-8:
    # su - postgres -c "/usr/lib/postgresql/12/bin/initdb --pgdata=/var/lib/postgresql/12/main --locale=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
  6. coder4web revised this gist Dec 3, 2019. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions postgresql_install.sql
    Original file line number Diff line number Diff line change
    @@ -34,6 +34,8 @@ sed -i 's/^host\s*all\s*all\s*127\.0\.0\.1\/32\s*ident/host all a
    # 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:
    # su - postgres -c "/usr/lib/postgresql/12/bin/initdb --pgdata=/var/lib/postgresql/12/main --locale=ru_RU.UTF-8"
    echo 'LC_COLLATE="ru_RU.UTF-8"' >> /etc/locale.conf
  7. coder4web revised this gist Dec 3, 2019. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions postgresql_install.sql
    Original file line number Diff line number Diff line change
    @@ -34,11 +34,12 @@ sed -i 's/^host\s*all\s*all\s*127\.0\.0\.1\/32\s*ident/host all a
    # nano /etc/apt/sources.list.d/pgdg.list
    deb http://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main

    #export LC_COLLATE="ru_RU.UTF-8"
    # ru_RU.UTF-8:
    # su - postgres -c "/usr/lib/postgresql/12/bin/initdb --pgdata=/var/lib/postgresql/12/main --locale=ru_RU.UTF-8"
    echo 'LC_COLLATE="ru_RU.UTF-8"' >> /etc/locale.conf
    # reboot!

    apt install postgresql-12 postgresql-contrib
    # su - postgres -c "/usr/lib/postgresql/12/bin/initdb --pgdata=/var/lib/postgresql/12/main --locale=ru_RU.UTF-8"
    sudo systemctl status postgresql.service
    sudo systemctl start postgresql.service
    sudo -i -u postgres
  8. coder4web revised this gist Dec 3, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions postgresql_install.sql
    Original file line number Diff line number Diff line change
    @@ -34,8 +34,8 @@ sed -i 's/^host\s*all\s*all\s*127\.0\.0\.1\/32\s*ident/host all a
    # nano /etc/apt/sources.list.d/pgdg.list
    deb http://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main

    #echo 'LC_COLLATE="ru_RU.UTF-8"' >> /etc/locale.conf
    export LC_COLLATE="ru_RU.UTF-8"
    #export LC_COLLATE="ru_RU.UTF-8"
    echo 'LC_COLLATE="ru_RU.UTF-8"' >> /etc/locale.conf

    apt install postgresql-12 postgresql-contrib
    # su - postgres -c "/usr/lib/postgresql/12/bin/initdb --pgdata=/var/lib/postgresql/12/main --locale=ru_RU.UTF-8"
  9. coder4web revised this gist Dec 3, 2019. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion postgresql_install.sql
    Original file line number Diff line number Diff line change
    @@ -34,7 +34,8 @@ sed -i 's/^host\s*all\s*all\s*127\.0\.0\.1\/32\s*ident/host all a
    # nano /etc/apt/sources.list.d/pgdg.list
    deb http://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main

    echo 'LC_COLLATE="ru_RU.UTF-8"' >> /etc/locale.conf
    #echo 'LC_COLLATE="ru_RU.UTF-8"' >> /etc/locale.conf
    export LC_COLLATE="ru_RU.UTF-8"

    apt install postgresql-12 postgresql-contrib
    # su - postgres -c "/usr/lib/postgresql/12/bin/initdb --pgdata=/var/lib/postgresql/12/main --locale=ru_RU.UTF-8"
  10. coder4web revised this gist Dec 3, 2019. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion postgresql_install.sql
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,7 @@ dnf install postgresql12 postgresql12-server
    #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="en_US.UTF-8"' >> /etc/locale.conf
    echo 'LC_ALL="ru_RU.UTF-8"' >> /etc/locale.conf

    #PGDATA='/srv/data/12/data'
    #PGSETUP_INITDB_OPTIONS="-D ${PGDATA}"
    @@ -33,6 +33,9 @@ sed -i 's/^host\s*all\s*all\s*127\.0\.0\.1\/32\s*ident/host all a
    # -------------------------------
    # nano /etc/apt/sources.list.d/pgdg.list
    deb http://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main

    echo 'LC_COLLATE="ru_RU.UTF-8"' >> /etc/locale.conf

    apt install postgresql-12 postgresql-contrib
    # su - postgres -c "/usr/lib/postgresql/12/bin/initdb --pgdata=/var/lib/postgresql/12/main --locale=ru_RU.UTF-8"
    sudo systemctl status postgresql.service
  11. coder4web revised this gist Dec 3, 2019. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions postgresql_install.sql
    Original file line number Diff line number Diff line change
    @@ -34,6 +34,7 @@ sed -i 's/^host\s*all\s*all\s*127\.0\.0\.1\/32\s*ident/host all a
    # nano /etc/apt/sources.list.d/pgdg.list
    deb http://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main
    apt install postgresql-12 postgresql-contrib
    # su - postgres -c "/usr/lib/postgresql/12/bin/initdb --pgdata=/var/lib/postgresql/12/main --locale=ru_RU.UTF-8"
    sudo systemctl status postgresql.service
    sudo systemctl start postgresql.service
    sudo -i -u postgres
  12. coder4web revised this gist Dec 3, 2019. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions postgresql_install.sql
    Original file line number Diff line number Diff line change
    @@ -34,6 +34,8 @@ sed -i 's/^host\s*all\s*all\s*127\.0\.0\.1\/32\s*ident/host all a
    # nano /etc/apt/sources.list.d/pgdg.list
    deb http://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main
    apt install postgresql-12 postgresql-contrib
    sudo systemctl status postgresql.service
    sudo systemctl start postgresql.service
    sudo -i -u postgres
    psql --version
    psql -l
  13. coder4web revised this gist Dec 3, 2019. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions postgresql_install.sql
    Original file line number Diff line number Diff line change
    @@ -34,3 +34,8 @@ sed -i 's/^host\s*all\s*all\s*127\.0\.0\.1\/32\s*ident/host all a
    # nano /etc/apt/sources.list.d/pgdg.list
    deb http://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main
    apt install postgresql-12 postgresql-contrib
    sudo -i -u postgres
    psql --version
    psql -l
    psql
    \password postgres
  14. coder4web revised this gist Nov 30, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion postgresql_install.sql
    Original file line number Diff line number Diff line change
    @@ -33,4 +33,4 @@ sed -i 's/^host\s*all\s*all\s*127\.0\.0\.1\/32\s*ident/host all a
    # -------------------------------
    # nano /etc/apt/sources.list.d/pgdg.list
    deb http://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main
    apt install postgresql12
    apt install postgresql-12 postgresql-contrib
  15. coder4web revised this gist Nov 30, 2019. 1 changed file with 9 additions and 1 deletion.
    10 changes: 9 additions & 1 deletion postgresql_install.sql
    Original file line number Diff line number Diff line change
    @@ -25,4 +25,12 @@ sed -i 's/^host\s*all\s*all\s*127\.0\.0\.1\/32\s*ident/host all a

    #msg "Set PGDATA to "${PGDATA}
    #sed -i "s~^Environment=PGDATA=.*~Environment=PGDATA=\${PGDATA}/~" /usr/lib/systemd/system/postgresql-12.service
    #systemctl daemon-reload
    #systemctl daemon-reload

    # -------------------------------
    # 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 install postgresql12
  16. coder4web revised this gist Nov 27, 2019. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion postgresql_install.sql
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,13 @@
    # RHEL / CentOS 8
    # https://www.postgresql.org/download/linux/redhat/
    # https://www.postgresql.org/docs/current/runtime.html

    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
  17. coder4web revised this gist Nov 13, 2019. 1 changed file with 7 additions and 3 deletions.
    10 changes: 7 additions & 3 deletions postgresql_install.sql
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,13 @@
    # RedHat-based
    # RHEL / CentOS 8
    # https://www.postgresql.org/download/linux/redhat/
    # https://www.postgresql.org/docs/current/runtime.html

    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
    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

    # 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="en_US.UTF-8"' >> /etc/locale.conf

  18. coder4web revised this gist Nov 13, 2019. 1 changed file with 8 additions and 0 deletions.
    8 changes: 8 additions & 0 deletions postgresql_install.sql
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,21 @@
    # RedHat-based
    # https://www.postgresql.org/download/linux/redhat/
    # https://www.postgresql.org/docs/current/runtime.html

    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="en_US.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
  19. coder4web revised this gist Oct 30, 2019. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions postgresql_install.sql
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,9 @@
    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="en_US.UTF-8"' >> /etc/locale.conf
    /usr/pgsql-12/bin/postgresql-12-setup initdb

    systemctl enable postgresql-12
    systemctl start postgresql-12

  20. coder4web revised this gist Oct 30, 2019. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions postgresql_install.sql
    Original file line number Diff line number Diff line change
    @@ -7,3 +7,5 @@ yum install postgresql12 postgresql12-server
    /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
  21. coder4web created this gist Oct 30, 2019.
    9 changes: 9 additions & 0 deletions postgresql_install.sql
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    # RedHat-based
    # https://www.postgresql.org/download/linux/redhat/

    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

    /usr/pgsql-12/bin/postgresql-12-setup initdb
    systemctl enable postgresql-12
    systemctl start postgresql-12