11/21/2023 0 Comments Ubuntu configure postgresql# The user demouser will be able access only the demodb from all locations using a md5 password # The user demouser will be able access all databases from all locations using a md5 password It will show output as below: LISTEN 0 128 0.0.0.0:5432 0.0.0.0:*Īt last, update pg_hba.conf file to configure the server to accept remote connections: # TYPE DATABASE USER ADDRESS METHOD Now confirm and verify the changes typing following in terminal: ss -nlt | grep 5432 Save the file and restart the PostgreSQL service using systemctl command: sudo service postgresql restart Listen_addresses = '*' # what IP address(es) to listen on Update listen_addresses like given below: #. You should edit configuration file /etc/postgresql/10/main/nf and add listen_addresses = '*' in the CONNECTIONS AND AUTHENTICATION section to enable remote access to your PostgreSQL server. Next execute following command which will grant permissions: grant all privileges on database demodb to demouser Enabling Remote Access to PostgreSQL server #īy default, the PostgreSQL server listens only on the local interface 127.0.0.1. So run below command to connect PostgreSQL shell: sudo -u postgres psql Now, you should grant permission to user demouser for newly created demodb database. To create a new database use the following command: sudo su - postgres -c "createdb demodb" Use the below command to create a new role: sudo su - postgres -c "createuser demouser" By using createdb method you can create a database in Postgres. You can only create if you are superuser or have roles with CREATEROLE privileges. You can use createuser command to create new roles from the command line.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |