您的位置:首页 > 数据库

新手安装postgreSQL后无法连接服务器

2016-04-28 00:00 190 查看
系统:Linux Deepin 15.1
postgreSQL:9.5.1
pgAdmin Ⅲ:1.22.0

使用新立得安装postgreSQL和pgAdminⅢ之后,打开pgAdmin需新建服务器。
打开新建服务器窗口后,名称可以随意填写,主机可以填localhost,端口默认5432,维护数据库默认postgres。
但用户名和密码无论咋填都无法连接服务器。

原因:新安装的postgreSQL里默认有一个数据库postgres,也有一个默认用户postgres,但该用户没有密码,而pgAdmin连接服务器必需填写密码。

解决方法:可以使用命令行窗口登录postgres数据库,然后修改用户postgres的密码。或者新建一个postgreSQL的用户,在设置密码。我采用的是第二种方案,步骤如下:
1、新建postgreSQL用户

sudo /bin/bash
# you should be root now
su postgres
# you are postgres now
createuser --interactive
#createuser会提示你建立一个新用户,在这里我建立了一个用户test

2、修改密码

#使用psql登录数据库postgres
psql postgres
#登录后使用\password命令修改test的密码
#注意:psql中的命令都是以"\"开头
postgres=# \password test

3、打开pgAdmin,新建服务器,填入刚刚设置的用户名和密码即可。

参考资料: http://stackoverflow.com/questions/24917832/how-connect-postgres-to-localhost-server-using-pgadmin-on-ubuntu
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: