CentOS7上安裝PostgreSQL,centos7postgresql

來源:互聯網
上載者:User

CentOS7上安裝PostgreSQL,centos7postgresql

  • 安裝postgresql軟體包
sudo yum install postgresql-server postgresql
  • 初始化db
sudo su - postgresinitdb -D /var/lib/pgsql/data
  • 啟動/停止服務
systemctl status postgresql.servicesystemctl start postgresql.servicesystemctl stop postgresql.service
  • 修改配置允許遠端存取

修改 /var/lib/pgsql/data/postgresql.conf 檔案

listen_addresses ='*'

修改 /var/lib/pgsql/data/pg_hba.conf 檔案**

host    all             all             0.0.0.0/0            trust
  • 修改完成後,重新啟動服務
systemctl restart postgresql.service
  • 建立使用者和資料庫
$ sudo su - postgres$ psql -U postgres -W$ Password for user postgres: postgrespostgres=# CREATE USER <user> WITH PASSWORD '<password>';postgres=# CREATE DATABASE test OWNER <user> ENCODING 'UTF8';
  • 測試
$ psql -U kongxx -d testtest=> \dt

著作權聲明:本文為博主原創文章,未經博主允許不得轉載。

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.