如何使用PSequel GUI连接到Mac上的localhost PostgreSQL? [英] How to connect to localhost PostgreSQL on Mac using PSequel GUI?
问题描述
我关注了本教程在我的Mac上安装PG.这是我第一次在本地使用PG.在此之前,我在Rails项目中经常使用Sqlite.
I followed this tutorial to install PG on my Mac. It's my first time using PG locally. I used Sqlite a lot in my Rails projects before this.
我找到了这个 PSequel GUI应用,并且我刚刚安装了它.但是我不知道如何连接到我的本地PostgreSQL数据库.
I found this PSequel GUI app and I just installed it. But I've no idea how to connect to my localhost PostgreSQL databases.
我是什么?
- 主机/套接字?
- 端口? (我使用
localhost:3000
在本地测试我的Rails应用) - 用户?
- 密码?
- 数据库?
- Host/Socket?
- Port? (I use
localhost:3000
to test my Rails app locally) - User?
- Password?
- Database?
谢谢.
推荐答案
localhost:3000
是 webrick 网络服务器.默认情况下,postgre SQL服务连接到5432
帖子上的localhost
.
localhost:3000
is the default url of webrick webserver. By default postgre SQL service connection is to localhost
on 5432
post.
$ cat /etc/services | grep postgres
postgres 5432/tcp # POSTGRES
postgres 5432/udp # POSTGRES
适用于unix
之类的系统.我有postgres
服务器在5432
端口上监听.
That is for unix
like systems. And I have postgres
server listening on 5432
port.
$ netstat -l --numeric-ports |grep 5432
tcp 0 0 localhost.localdomain:5432 *:*
unix 2 [ ACC ] STREAM LISTENING 11396 /tmp/.s.PGSQL.5432
因此这些字段将具有以下默认值:
So the fields will have the following default values:
-
主机/套接字
localhost
出于测试/开发目的,大多数人使用本地服务器连接到数据库.
For test/development purposes most people use local server to connect to db.
端口
5432
那只是postgres
服务器(不是Web服务器)的连接端口.要验证,只需列出并grep postgres
配置文件,如下所示:
That is just postgres
server (not webserver) connection port. To validate just list and grep the postgres
configuration file, like follows:
# cat /var/lib/pgsql/data/postgresql.conf | grep port
#port = 5432 # (change requires restart)
此处已被注释掉,因此将应用默认值.
Here it is commented out, so default values are applied.
用户
您是,但是您必须创建用户角色从postgres
用户使用createuser
或psql
终端实用程序进行连接之前.
you are, but you must create the user role before connection as of the postgres
user with createuser
or psql
terminal utilities.
密码
创建用户时,只需将密码保留为空.这样您就可以在表格中将该字段保留为空.
When you will create the user just leave password empty. So you be able then stay the field empty in the form.
数据库
这是数据库名称.
这篇关于如何使用PSequel GUI连接到Mac上的localhost PostgreSQL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!