postgresql – 授予postgres超级用户到linux帐户
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了postgresql – 授予postgres超级用户到linux帐户,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1306字,纯文字阅读大概需要2分钟。
内容图文
![postgresql – 授予postgres超级用户到linux帐户](/upload/InfoBanner/zyjiaocheng/897/856eea7a47744dafbd3c1fe8ef9cb04e.jpg)
在我的开发(Ubuntu linux)笔记本电脑上,我有一个postgres操作系统帐户,它拥有Postgres安装.
当我想执行任何postgres活动,创建/删除数据库等时,我必须首先su到postgres帐户.
$sudo su postgres
如何更改自己的操作系统帐户以获得操作系统级别的postgres特权,所以我不需要su?
解决方法:
在OS上创建用户
# Identify yourself as root
su -
# Create the user who will have access to a postgres database
useradd mypostgresuser
# Add a password
passwd mypostgresuser
授予本地用户访问postgres的权限
您需要找到postgresql安装的数据目录,即您已创建数据库文件的位置.它们通常位于/ var / lib / pgsql / data中
安装的值可能在环境变量$PGDATA中可用
# Make sure that local users can access postgres
cat /${PGDATA}/pg_hba.conf
# this was the default setting on my 8.4 install
# TYPE DATABASE USER CIDR-ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all
如果你做了任何改变,重新加载postgres将是必要的
/etc/init.d/postgresql reload
或者作为postgres
pg_ctl reload -D ${PGDATA}
现在连接到psql作为postgres
# Create the user in postgres
postgres=# create user mypostgresuser;
CREATE ROLE
# Give that user access to a database
postgres=# grant all privileges on database mytestdb to mypostgresuser;
GRANT
测试连接
# Identify yourself as mypostgresuser
su - mypostgresuser
# Connect to the database
psql -d mytestdb
内容总结
以上是互联网集市为您收集整理的postgresql – 授予postgres超级用户到linux帐户全部内容,希望文章能够帮你解决postgresql – 授予postgres超级用户到linux帐户所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。