能夠參考postgresql官網安裝教程:https://www.postgresql.org/download/linux/redhat/linux
Centos 6 安裝postgresql 10sql
添加RPM:數據庫
-- centos 6 安裝 postgresql 10 yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-6-x86_64/pgdg-centos10-10-2.noarch.rpm -- centos 7 安裝 postgresql 10 yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm
安裝客戶端:centos
yum install postgresql10
安裝服務端:bash
yum install postgresql10-server
啓動數據並初始化:post
service postgresql-10 initdb chkconfig postgresql-10 on service postgresql-10 start
# su - postgres -- 首先切換到postgres -bash-4.1$ psql -- 輸入psql psql (10.5) Type "help" for help. postgres=#
建立用戶spa
postgres=# create user username with password '****'; CREATE ROLE postgres=#
須要注意:postgresql
1. 要以英文分號結尾code
2.密碼須要引號包裹server
建立數據庫
postgres=# create database dbtest owner username; -- 建立數據庫指定所屬者 CREATE DATABASE postgres=#
將數據庫得權限,所有賦給某個用戶
postgres=# grant all on database dbtest to username; -- 將dbtest全部權限賦值給username GRANT postgres=#
導入整個數據庫
psql -U username databasename < /data/dum.sql -- 用戶名和數據庫名