新建postgresql数据库的方法
这篇文章将为大家详细讲解有关新建postgresql数据库的方法,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。
一、安装
可以参考postgresql官网安装教程:https://www.postgresql.org/download/linux/redhat/
Centos 6 安装postgresql 10
添加RPM:
--centos6安装postgresql10yuminstallhttps://download.postgresql.org/pub/repos/yum/10/redhat/rhel-6-x86_64/pgdg-centos10-10-2.noarch.rpm--centos7安装postgresql10yuminstallhttps://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm
安装客户端:
yuminstallpostgresql10
安装服务端:
yuminstallpostgresql10-server
启动数据并初始化:
servicepostgresql-10initdbchkconfigpostgresql-10onservicepostgresql-10start
二、创建用户和数据库
#su-postgres--首先切换到postgres-bash-4.1$psql--输入psqlpsql(10.5)Type"help"forhelp.postgres=#
创建用户
postgres=#createuserusernamewithpassword'****';CREATEROLEpostgres=#
需要注意:
(1)要以英文分号结尾
(2)密码需要引号包裹
创建数据库
postgres=#createdatabasedbtestownerusername;--创建数据库指定所属者CREATEDATABASEpostgres=#
将数据库得权限,全部赋给某个用户
postgres=#grantallondatabasedbtesttousername;--将dbtest所有权限赋值给usernameGRANTpostgres=#
三、数据库的导入导出
导入整个数据库
psql-Uusernamedatabasename</data/dum.sql--用户名和数据库名
关于新建postgresql数据库的方法就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。