postgresql 如何在 Ubuntu 上使用 pgAdmin 将 Postgres 连接到 localhost 服务器?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24917832/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How connect Postgres to localhost server using pgAdmin on Ubuntu?
提问by TuGordoBello
I installed Postgres with this command
我用这个命令安装了 Postgres
sudo apt-get install postgresql postgresql-client postgresql-contrib libpq-dev
Using psql --version
on terminal I get psql (PostgreSQL) 9.3.4
psql --version
在终端上使用我得到psql (PostgreSQL) 9.3.4
then I installed pgadmin
with
然后我安装pgadmin
了
sudo apt-get install pgadmin3
Later I opened the UI and create the server with this information
后来我打开了 UI 并用这些信息创建了服务器
but this error appear
但是出现这个错误
how can I fix it?
我该如何解决?
采纳答案by Eric Workman
You haven't created a user db
. If its just a fresh install, the default user is postgres
and the password should be blank. After you access it, you can create the users you need.
您尚未创建用户db
。如果只是全新安装,则默认用户是postgres
,密码应为空。访问它后,您可以创建所需的用户。
回答by WiredIn
Modify password for role postgres:
修改 postgres 角色的密码:
sudo -u postgres psql postgres
alter user postgres with password 'postgres';
Now connect to pgadmin using username postgres and password postgres
现在使用用户名 postgres 和密码 postgres 连接到 pgadmin
Now you can create roles & databases using pgAdmin
现在您可以使用 pgAdmin 创建角色和数据库
回答by Artem Solovev
It helps me:
它帮助到我:
1. Open the file打开文件
pg_hba.conf
pg_hba.conf
sudo nano /etc/postgresql/9.x/main/pg_hba.conf
须藤纳米 /etc/postgresql/9.x/main/pg_hba.conf
and change this line:
并更改此行:
Database administrative login by Unix domain socket
local all postgres md5
to
到
Database administrative login by Unix domain socket
local all postgres trust
Restart the server
sudo service postgresql restart
Login into psqland set password
psql -U postgres
重启服务器
须藤服务 postgresql 重启
登录psql并设置密码
psql -U postgres
ALTER USER postgres with password 'new password';
ALTER USER postgres with password 'new password';
- Again open the file
pg_hba.conf
and change this line:
- 再次打开文件
pg_hba.conf
并更改这一行:
Database administrative login by Unix domain socket local all postgres trust
to
到
Database administrative login by Unix domain socket local all postgres md5
- Restart the server
sudo service postgresql restart
- 重启服务器
须藤服务 postgresql 重启
有用。
有用的链接
1:PostgreSQLPostgreSQL(来自 ubuntu.com)
回答by Str.
Create a user first. You must do this as user postgres. Because the postgres system account has no password assigned, you can either set a password first, or you go like this:
首先创建一个用户。您必须以 postgres 用户身份执行此操作。因为 postgres 系统帐户没有分配密码,你可以先设置密码,或者像这样:
sudo /bin/bash
# you should be root now
su postgres
# you are postgres now
createuser --interactive
and the programm will prompt you.
程序会提示你。
回答by Pubudu
First you should change the password using terminal. (username is postgres)
首先,您应该使用终端更改密码。(用户名是 postgres)
postgres=# \password postgres
postgres=# \password postgres
Then you will be prompted to enter the password and confirm it.
然后系统会提示您输入密码并确认。
Now you will be able to connect using pgadmin with the new password.
现在您将能够使用 pgadmin 使用新密码进行连接。
回答by Elise Chant
if you open the psql
console in a terminal window, by typing
如果您psql
在终端窗口中打开控制台,请键入
$ psql
$ psql
you're super user username will be shown before the =#
, for example:
您是超级用户的用户名将显示在 之前=#
,例如:
elisechant=#
$
elisechant=#
$
That will be the user name you should use for localhost.
这将是您应该用于 localhost 的用户名。