Find the host name and port using PSQL commands

前端 未结 13 2201
眼角桃花
眼角桃花 2020-12-12 11:15

I have PSQL running, and am trying to get a perl application connecting to the database. Is there a command to find the current port and host that the database is running on

相关标签:
13条回答
  • 2020-12-12 11:18
    service postgresql status
    

    returns: 10/main (port 5432): online

    I'm running Ubuntu 18.04

    0 讨论(0)
  • 2020-12-12 11:22

    go to the "Terminal" and just type

    service postgres status
    

    In the results you can get the port details

    In my case it's running on port "5432" (default).
    I'm using CentOS 7.Hope this helps.

    0 讨论(0)
  • 2020-12-12 11:25
    SELECT *
    FROM pg_settings
    WHERE name = 'port';
    
    0 讨论(0)
  • 2020-12-12 11:28

    You can use the command in psql \conninfo you will get You are connected to database "your_database" as user "user_name" on host "host_name" at port "port_number".

    0 讨论(0)
  • 2020-12-12 11:33

    select inet_server_port(); gives you the port of the server.

    0 讨论(0)
  • 2020-12-12 11:34
    select inet_server_addr( ), inet_server_port( );
    
    0 讨论(0)
提交回复
热议问题