设为首页 加入收藏

TOP

step by step设置postgresql用户密码并配置远程连接
2019-09-03 03:23:39 】 浏览:16
Tags:step 设置 postgresql 用户 密码 配置 远程 连接

设置pgsql默认用户posgres的密码

1、确认pgsql是开启的 /etc/init.d/postgresql status
2、使用默认用户登录 sudo su postgres
3、进入psql客户端 命令为 sudo -u postgres psql 进入之后就可以写sql了
4、执行第三步如果出现“postgres is not in the sudoers file.  This incident will be reported.”提示则需要在sudoers里面加上postgres,步骤如下:
        1) 输入命令 su - 进入超级用户模式(如果当前不是root用户,则进行root身份验证);
        2) chmod u+w /etc/sudoers 为sudoers文件添加写的权限(默认是只读)
        3) vim /etc/sudoers 编辑sudoers文件,在root ALL=(ALL) ALL这一行下面加上 postgres  ALL=(ALL) ALL
        4)撤销sudoers文件可写 chmod u-w /etc/sudoers
5、继续执行第三步,进入psql客户端之后执行 postgres=# ALTER USER postgres with password '123456';(将默认的postgres用户密码设置为123456,注意语句后面一定要加分号),postgres=# \q 退出psql客户端
 

设置pgsql远程连接

1、修改pgsql配置文件postgresql.conf(默认位于安装目录的data子文件夹下)。找到 listen_addresses = 'localhost' 这一行,将localhost修改为 * 所有ip都允许连接,并取消注释
2、port = 5432 取消注释
3、修改pg_hda.conf(和postgresql.conf同一个目录),在末尾加一行  host    all         all         0.0.0.0/0      md5
4、开启5432端口:
iptables -I INPUT -p tcp --dport 5432 -j ACCEPT 
/etc/init.d/iptables save
/etc/init.d/iptables restart
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇PostgreSQL 9.3发布 下一篇非关系型数据库SequoiaDB虚拟机下..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目