Importing files from PostgreSQL to R

前端 未结 3 658
日久生厌
日久生厌 2020-12-25 15:18

I have a large data-set and I will preform some analysis in R software. While I could not import the data properly to R.

I get this error:

Error in postgr         


        
3条回答
  •  既然无缘
    2020-12-25 16:05

    You have to configure two things on the PostgreSQL server before you are able to connect remotely. This is a instruction how to configure this under Linux:

    1. Find and configure postgresql.conf to allow the TCP service to accept connections from any host, not only localhost

    find / -name "postgresql.conf"

    In my linux OS the file is locate in /etc/postgresql/9.6/main/, so I modify it there. Add the line "listen_addresses = '*'" as follows:

    /etc/postgresql/9.6/main/postgresql.conf

    #listen_addresses = 'localhost'         # what IP address(es) to listen on;
    # insert the following line
    listen_addresses = '*'
    

    2. Find and configure pg_hba.conf to allow to connect with a client from any host

    sudo find / -name "pg_hba.conf"

    In my linux OS the file is locate in /etc/postgresql/9.6/main/, so I modify it there. Add the line "host all all 0.0.0.0/0" as follows:

    sudo nano /etc/postgresql/9.6/main/pg_hba.conf

    # Put your actual configuration here
    # ----------------------------------
    #
    # If you want to allow non-local connections, you need to add more
    # "host" records.  In that case you will also need to make PostgreSQL
    # listen on a non-local interface via the listen_addresses
    # configuration parameter, or via the -i or -h command line switches.
    #
    # insert the following line
    host all all 0.0.0.0/0 trust
    

    3. Stop and start the server

    sudo service postgresql stop

    sudo service postgresql start

    4. Connect with you client, now it should work.

    GOOD LUCK!

提交回复
热议问题