PostgreSQL: One database to multiple user - postgresql

I have PostgreSQL 9.3 version. I have created database name db1 now I need it to share with other users who all are connected with the LAN's to connect other applications with the same database.
In SQL Server: We can do this by selecting server name with login details.
Question:
Is it possible in PostgreSQL?
If yes, how can do this?
What is the procedure?

You will need to modify pg_hba.conf to allow remote connections to the database. Information about pg_hba.conf can be found here.
After that, you can connect programatically with a connection string, or similar to your image, with a GUI application like pgAdmin.
To connect (remotely or locally) from pgAdmin choose File -> Add Server... and enter the connection information into the dialog box. Here's an example of the window:
Your client computers will also need to have PostgreSQL drivers as well. If you're doing this in Windows, you'll probably be using ODBC. The PostgreSQL ODBC drivers are here. Info on the connection string format can be found here.
Here's an example of what pgAdmin looks like:

Related

postgresql pg library taking windows username instead of postgresql

i am using pg lib in strapi application, where initially it creates postgres connection using correct postgresql username(postgres), database name(strapi_db) and password(postgres) but after login it changed it to connect using my windows 10 username(rayappan.a, and database as rayappan.a). it seems strange to me because i never configured anywhere to use my windows credentials for POSTGRESQL connection. please any one tell me how to fix username connection issue
Regards,
Rayappan Antoniraj
Take a look into https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING . It states that username:
Defaults to be the same as the operating system name of the user running the application."
The database name:
Defaults to be the same as the user name.
So it seems a new connection with parameters not set is made.

How to connect to database through JDBC in pgAdmin?

I have database connection settings and pgAdmin (it is all that i have). Can I connect to the database through the pgAdmin to make the necessary changes in the database using these settings? If so, how?
I have not found how I can do this. Other answers here (and in google too) suggest writing Java-code - this is not what i need. I want to use pgAdmin interface for it. Can I make changes without using Java-code?
Here example of settings that i have:
jdbc.driverClassName - org.postgresql.Driver
jdbc.url - jdbc:postgresql://localhost:4444/
jdbc.username - username
jdbc.password - password
I don't understand why people don't understand what he's trying to do. He just wants to connect to db using pgAdmin. He just doesn't understand how to use the connection string in pgAdmin.
Basically, just remove all prefixes and suffixes (eg. jdbc:postgresql://). So your hostname is localhost. Type localhost in host name, 4444 in port name as well as your username and password. Also give it a name in General tab Then you'll see the databases on the left. Click Tools > Query Tool and write your select/insert etc. scripts.

How do I connect to the Divio postgres database with local PgAdmin?

I am trying to connect with PgAdmin to the local Divio database in the container but PgAdmin 4 will not let me connect without a password. The Divio Postgres database seems to come without a password.
Has anyone got round this?
You don't need a password.
See Interact with the local database from your host environment in the official documentation.
The key things are:
expose the database’s port by editing the docker-compose.yml file
use the correct credentials
Both steps are described in more detail in the documentation. I haven't given more specific details here such as port numbers in case those details ever change in the future.

Remote Database Connection Setup in Netbeans

I'm totally junior in this area :)
I have JAVA version 7 on my PC.
I want to connect my PostgreSQL database to NetBeans.
Based on my search I found that I should get JDBC driver. so I downloaded JDBC41 Postgresql Driver, Version 9.3-1100 jar files from here.
then based on what I found for connection remote Mysql, did similar changes to connect to my PostgreSQL database.
As you can see in the image, connection couldn't established.
Based on what my host says, I added my IP address to "Remote PostgreSQL Database Access" page of my host.
I'm not sure my host name is correct. I used Dedicated IP Address of my site.
Any suggestion would be appreciated. Thanks
My fault was entering wrong user name and pass instead of using user name and password of database :(

How does ODBC pull database connection details?

I currently have a Macro which is connecting to a sybase database using ODBC. It's making the connection by running the following:
Set conX = wrkODBC.OpenConnection("Connection1", , True, strConn)
where strConn = "ODBC;DSN=Server_Name;APP=Daily Task;DB=db_name;UID=uname;PWD=pwd;"
The problem I am having is that this connection is working for some Server_Name's but not others. When it doesn't work I get a Error "3146 - ODBC--call failed".
What I don't understand is where it is pulling the server details from. So for example, when using embarcadero rapid to connect to a sybase database, it will use the sql.ini file to pull the server connection details based on the server_name.
I have checked and all the Sybase Servers I am testing are in the sql.ini file and my env variables are pointing to the correct sybase version. I've checked ODBC and it is only picking up a SQL Server driver.
Can anyone please explain how ODBC pulls the server name connection details? I don't understand why it works for some server names, but not others (FYI, I have tested the uname and pwd is rapid to make sure it is correct).
Any information would be much appreciated.
So, the issue was that I was looking at my odbc connections under control panel. I should mention that I am on windows 7. What I had to do was update my ODBC connection details here:
C:/Windows/SYSWOW64/odbcad32.exe
--This is for 32bit!
This had some connections set up which is why I could connect to some servers but not all of them.