How to connect Odoo with postgres (which is running on other server) - postgresql

I want to connect odoo 10 with the postgresql (which is running on other server). Is it possible ? If, yes! then please do help me out by posting step by step procedure or any sort of tutorial link (because I'm beginner). For now, I'm using odoo10 and postgresql-9.6 For different servers I'm using two different virtual machines (one is for odoo & other is for postgresql)
Here, I'm using two virtual machines 216.200.116.8 (for odoo) & 216.200.116.174 (for postgresql). I'm able to access postgresql from 216.200.116.8 remotely.
Here is my /etc/odoo.conf
Here is my /etc/postgresql/9.6/main/postgresql.conf
Here is my /etc/postgresql/9.6/main/pg_hba.conf
After everything is configured I'm running odoo server from /opt/odoo/odoo10.0/odoo-bin
I've encountered this error! The detailed error says:
Odoo ver : 10 & postgresql ver : 9.6
Database User :postgres
password for postgres: passwd
Help needed! Thanks in Advance

If I am not mistaken, you must change the user in the database, odoo doesn't allow "postgres" as the user, you must create an "odoo user" to connect the application to the database like this:
db_user: odoo
db_password: yourpassword
Then in the postgres.conf file you must change this line:
listen_adresses = 'localhost'
I can't remember if something must be changed in the .hba

You need to change in pg_hba.conf file
In IPV4 section , you need to replace 1 line with below change.
host all all 0.0.0.0/0 trust
This is for first line in IPV4 section.
After Restart PostgreSQL , you can connect.

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.

Tableau Desktop connection to PostgreSQL DB using Certificate Authentication over SSL/TLS

I connect to my PostgreSQL databases (which run on AWS EC2 instances) using certificate authentication (and not passwords). An example of a psql command I would use to connect to one of my databases is:
psql "host=<AWS EC2 instance> user=<db user> sslcert=<path to .crt> sslkey=<path to .key> sslrootcert=<path to .crt> sslmode=require dbname=<db name>"
I would like to be able to connect Tableau Desktop to one of my databases. The standard PostgreSQL connector does not allow me to specify which SSL certs to use (but it does have a Require SSL checkbox - which I think is for encryption not authentication).
So I have tried to use the ODBC connector. I make the following entries:
Connect Using
Driver: PostgreSQL Unicode
Connection Attributes
Server: <AWS EC2 instance>
Port: 5432
Database: <db name>
Username: <db user>
String Extras: sslcert=<path to .crt>; sslkey=<path to .key>; sslrootcert=<path to .crt>; sslmode=require
By much trial and error I think the String Extras require a semicolon as a delimiter, but I still cannot connect. I get the error message:
An error occurred while communicating with Other Databases (ODBC).
Unable to connect to the server. Check that the server is running and that you have access privileges to the requested database.
FATAL: connection requires a valid client certificate
Generic ODBC requires additional configuration. The driver and DSN (data source name) must be installed and configured to match the connection.
Unable to connect to the server "<AWS EC2 instance>" using the driver "PostgreSQL Unicode". Check that the server is running and that you have access privileges to the requested database.
I would be really grateful to hear from anyone who has connected Tableau Desktop to PostgreSQL using certificate authentication and could tell me what I’m doing wrong. Cheers!
I managed to fix this myself, and just in case there's someone out there who might be vaguely interested I'll go through the salient features:
1. Created a DSN (Data Store Name)
This made testing much easier rather than constantly retyping details into dialog boxes.
Rather than create manually I used this: http://www.odbcmanager.net/
On Mac OS I had to run it as sudo from the terminal or it wouldn't create anything.
I created a User DSN, which on my Mac have details stored in /Users/<user name>/.odbc.ini
It picked up the PostgreSQL Unicode driver that I'd previously installed. On Mac OS you might need to do brew install brew install psqlodbc and/or brew install unixodbc
Most of the configuration was specified by adding key/value pairs e.g. DBNAME <db name>
Set SSLMODE verify-ca (changed from require to make behaviour specific - psql assumes verify-ca/verify-full if SSL certs are supplied)
The cert paths are set with key Pqopt, value sslcert=<path to .crt> sslkey=<path to .key> sslrootcert=<path to .crt>. Must be lower case and only spaces between entries!
Here's what it added to my user's odbc.ini file:
[<DSN name>]
Driver = <path to driver, this was mine /usr/local/lib/psqlodbcw.so>
Description = <description>
SSLMODE = verify-ca
HOST = <host>
DBNAME = <database>
PORT = 5432
UID = <db user>
Pqopt = sslcert=<path to .crt> sslkey=<path to .key> sslrootcert=<path to .crt>
2. Tableau Desktop Connection
Select Other Database (ODBC) connector.
Select the DSN you created previously (it should be automatically picked up), it will automatically populate host, port, db and user fields, then click Sign In.
Once signed in behaviour was slightly different to the dedicated PostgreSQL connector. Tables did not appear on left-hand side initially. But they are accessible - they can all be displayed by clicking on the 'contains' radio button and searching with a blank name.
Hope this helps. Let me know if you've got any questions.

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.

How to connect PGAdmin3 to Cloud66 hosted Postgres

I have a Cloud66 hosted web app and Postgres database (on a dedicated server)
I'd like to connect to the Postgres DB via PGAdmin3 but I have been unable to configure Postgres to accept my connection.
I have added the following line to pg_hba.conf
host all all 86.161.230.162/32 md5
I have checked that postgresql.conf has the following setting:
listen_addresses = '*'
Any ideas?
The doubt in my mind is - Am I editing the correct version of these files? They took me a while to find and now I'm wondering if maybe there not the correct versions. These files are located in the directory
./usr/local/pgsql/data/
Advice/guidance all appreciated.
School boy error.
Of course. Firewall!
Doh.

Password authentication fails when trying to connect to postgresql from clojure with jdbc

I'm learning web development in Clojure and I'm not at all an expert in either PostgreSQL or JDBC.
I'm going through the "Web development with Clojure" book and I'm stuck because I cannot connect to a PostgreSQL database, although I believe I have followed the tutorial step by step.
I connected to psql with
sudo -u postgres psql
Then I created an admin user with password 'admin'
postgres=# CREATE USER admin WITH PASSWORD 'admin';
CREATE ROLE
Then I created a database named reporting :
postgres=# CREATE DATABASE reporting OWNER admin;
CREATE DATABASE
No complaints so far.
Then from my clojure code, I attempt to connect to the database and create a table :
(ns reporting-example.models.db
(:require [clojure.java.jdbc :as sql]))
;defining the db connection
(def db
{:subprotocol "postgresql"
:subname "//localhost/reporting"
:user "admin"
:password "admin"})
;function for creating an 'employee' table
(defn create-employee-table []
(sql/create-table :employee
[:name "varchar(50)"]
[:occupation "varchar(50)"]
[:place "varchar(50)"]
[:country "varchar(50)"])
)
; then trying to actually create the table, here's the part that breaks with an exception :
(sql/with-connection db
(create-employee-table))
And I'm getting an ugly :
org.postgresql.util.PSQLException: FATAL: password authentication failed for user "admin"
Which does not make sense to me, the credentials seem fine.
I tried the above code from both the Counterclockwise REPL and the Leiningen REPL. I'm on Ubuntu 13.10, if that matters.
Could someone explain to me what I am doing wrong here?
Thanks in advance!
Since you can't connect with psql using the same settings there are really three possibilities:
wrong/typo'd password
wrong/typo'd username
you are not connecting to the same server as you created the account on.
To check the latter, connect however you did to create the account and then run
show port;
Make sure it is the same as what you specify in your app. That isn't perfect - two pg instances can share a port if one isn't listening on TCP/IP and has a different socket directory - but it is a good first test.
You should also examine the PostgreSQL server error logs, as they may contain more detailed information about the nature of the authentication failure.
If you have not tried this already, review your pg_hba.conf file. It will be named something like
/etc/postgresql/9.6/main/pg_hba.conf (Ubuntu 16.04)
/var/lib/pgsql/9.3/data/pg_hba.conf (Fedora 20);
You may have to use find / -name pg_hba.conf to locate it.
At the bottom of the file, change the METHOD values to trust for local testing (see postgres docs for full information). Restart postgres to ensure everything is started clean and the new params are read:
> sudo systemctl restart postgresql # ubuntu
Hopefully this will cure your woes. It solved my problems on Ubuntu/Fedora.