Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect to localhost PostgreSQL on Mac using PSequel GUI?

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.

I found this PSequel GUI app and I just installed it. But I've no idea how to connect to my localhost PostgreSQL databases.

enter image description here

What is my:

  1. Host/Socket?
  2. Port? (I use localhost:3000 to test my Rails app locally)
  3. User?
  4. Password?
  5. Database?

Thanks.

like image 732
Zulhilmi Zainudin Avatar asked Feb 08 '23 22:02

Zulhilmi Zainudin


1 Answers

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

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:

  1. Host/Socket

    localhost
    

    For test/development purposes most people use local server to connect to db.

  2. Port

    5432
    

    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.

  3. User

    you are, but you must create the user role before connection as of the postgres user with createuser or psql terminal utilities.

  4. Password

    When you will create the user just leave password empty. So you be able then stay the field empty in the form.

  5. Database

    That is the database name. Create it with the command if needed.

like image 102
Малъ Скрылевъ Avatar answered Feb 13 '23 14:02

Малъ Скрылевъ