Openerp 7.0 error database - postgresql

i have a problem with Openerp, can you help me please ?
ERROR ? openerp.sql_db: Connection to the database failed
Traceback (most recent call last):
File "/opt/openerp/server/openerp/sql_db.py", line 440, in borrow
result = psycopg2.connect(dsn=dsn, connection_factory=PsycoConnection)
OperationalError: fe_sendauth: no password supplied

Check your /etc/openerp/openerp-server.conf and make sure you have at least the following options set:
db_host = (usually localhost)
db_port = (usually 5432)
db_user =
db_password =
Try connecting to your database manually by running:
psql -d postgres -U <YOUR DATABASE USERNAME> -W
If this works (you should get a prompt like "postgres=>", exit it by pressing ctrl+d) but the error is still there in OpenERP, its probably because you run Ubuntu/Debian and you just installed your OpenERP package. The error appears because the init script are not able to kill the first openerp Python process started by dpkg automatically after the package installation. To fix this, run:
# ps aux|grep openerp
You will see a line that looks something like this:
openerp 14438 0.3 0.8 235096 69060 ? Sl 03:23 0:00 /usr/bin/python /usr/bin/openerp-server --config=/etc/openerp/openerp-server.conf --logfile=/var/log/openerp/openerp-server.log
The first number is the pid of the Python process. Kill the process by running:
kill -9 14438
Then restart your openerp server again by running:
/etc/init.d/openerp restart
Your openerp-server.conf should now be re-read by OpenERP and the error should disappear.

Search Google and Stack Overflow for "fe_sendauth: no password supplied".
Your PostgreSQL is set up to require a password for the (address,database,user) combination you're connecting with and you aren't sending a password.
You can learn more by reading the Client Authentication chapter of the PostgreSQL documentation.

create a postgres user using this command.
make sure the user is named same to your system user.
sudo su postgres
createuser -d -S -R <your system user>
psql
alter user <your system user> with password <your password>;
Hope it will resolve your issue to establish connection with database.

Go to your opererp-server.conf and look for addons_path. Make sure you have /openerp/addons and /openerp/web/addons. if you have something else just take it off and restart your server. It will work.

Related

Configuration issue Postgres on Ubuntu?

I have installed Postgres 12 on Ubuntu by building it from source and I am facing two issues:
Although I followed the installation manual from Postgrez, every time I restart my computer, my Postgres server stopz and is no longer seen as a running process.
To start it the first time after install, I do this from the terminal:
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
/usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start
After a restart, to start DB again when I run: /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data, it throws this error:
initdb: error: directory "/usr/local/pgsql/data" exists but is not empty
If you want to create a new database system, either remove or empty
the directory "/usr/local/pgsql/data" or run initdb
with an argument other than "/usr/local/pgsql/data".
Does that mean that every time I start Postgres after a restart, I have to create a new /data directory?
Upon installing Postgres sing pip or pip3, one can just switch user to postgres and run psql to enter postgres, however now I have to run "/usr/local/bin/psql". Please note I have exported all the paths per https://www.postgresql.org/docs/12/installation.html. How can I fix this? Can an alias be set for this?
After a restart, to start DB again when I run:
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data, it throws this
error:
Does that mean that every
time I start Postgres after a restart, I have to create a new /data
directory?
No, quite the opposite. You don't need to initdb after the first time, you just need to start. It is your attempt to initdb when you don't need to which is causing the error message. Note that attempting to initdb isn't doing any harm, because it refused to run. It just generates log/console noise.
Upon installing Postgres sing pip or pip3, one can just switch user to
postgres and run psql to enter postgres, however now I have to run
"/usr/local/bin/psql". Please note I have exported all the paths per
https://www.postgresql.org/docs/12/installation.html. How can I fix
this?
I don't know what your first sentence means, as you don't use pip or pip3 to install PostgreSQL (or at least, the docs don't describe doing so) although you might use them to install psycopg2 to enable python to talk to PostgreSQL.
You could use an alias, but it would probably make more sense to edit ~/.bash_profile to set the PATH, as described from the page you linked to under Environment Variables.
You have to register postgreSQL as a service.
run this:
pg_ctl register [-N servicename] [-U username] [-P password] [-D datadir] [-S a[uto] | d[emand] ] [-w] [-t seconds] [-s] [-o options]
Example:
pg_ctl register -N postgresql -U OS_username -P OS_password -D '/etc/postgresql/12/data' -w
More info in the manual: pg_ctl
Notes:
Username and Password is related to the OS, not postgresql
If you have doubts read the manual.
/usr/local/pgsql/bin/pg_ctl start -D '/usr/local/pgsql/data'
Export following in postgres user account's ~/.bashrc:
LD_LIBRARY_PATH=/usr/local/pgsql/lib
export LD_LIBRARY_PATH
PATH=/usr/local/pgsql/bin:$PATH
export PATH

PostgreSQL server fails to start on ArchLinux: FATAL: could not create lockfile »/run/postgresql/.s.PGSQL.5432.lock«

I am quite new in Arch and a total beginner in PostgreSQL, so this may be a very basic question.
I installed postgresql 11.5-4 from extra and pgadmin 4 from AUR, both seem to be running well.
I created a test DB with the following command:
initdb -D /home/lg/test-db
I got the answer:
You can start the db-server using:
pg_ctl -D /home/lg/test-db -l logdatei start
I tried that and got:
pg_ctl -D /home/lg/test-db -l logdatei start
waiting for serer to start.... stopped
pg_ctl: could not start the server
check the log.
The log only says that the lockfile »/run/postgresql/.s.PGSQL.5432.lock« could not be created, because the folder could not be found. Under /run is no folder called "postgresql". I suppose postgresql can not create this folder, because it does not have the permission. Several posts online posts suggest to change the user/owner of the db to sudo, however. Postgresql prevents this, however. When I try any command as sudo, postgresql tells me that this command can't be run as root. There must be some very basic error in my thinking here, but I have not worked it out for 3 hours.
You'll have to remove /run/postgresql from unix_socket_directories in postgresql.conf before starting the server.
Probably You have /var/run symlinked to /run and run is on tmpfs. You should add something like d /run/postgresql 0755 postgres postgres - into /usr/lib/tmpfiles.d/postgresql.conf

Unable to start sever, likely due to misplaced .conf. How do can I verify the cause and find/replace .conf?

I'm new to psql, and am having some issues that I think are being caused by a misplaced .conf file. When I tried to log into a database I created earlier I get an error
$ psql corporation
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
Based on the psql docs it looks like the server isn't running and ps confirms this. Since I don't remember having to start it last time I used psql I was a little confused, but it seemed easy to fix. Unfortunately, my attempts to start the sever have not worked. Using the first method suggested by the docs gets me
$ postgres -D /usr/local/pgsql/data
postgres cannot access the server configuration file "/usr/local/pgsql/data/postgresql.conf": No such file or directory
While the second method results in
$postgres -D /usr/local/pgsql/data >logfile 2>&1 &
[1] 3165
Ps confirms that neither of these methods started postgres, and when I tried to open the database anyway, to double check, it returns a slightly different error message than before.
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
[1]+ Exit 2 postgres -D /usr/local/pgsql/data > logfile 2>&
How to start PostgreSQL server on Mac OS X? seems related, but has some gaps. Just running initdb wasn't enough, and I don't seem to have a .conf.sample. Do I just need to create a new .conf from scratch or what?
For reference I'm running Snow Leopard, I originally tried to manually instal psql, but ended up installing brew then brew installing psql.
Have you tried doing a find?
sudo find / -name postgresql*

Socket File "/var/pgsql_socket/.s.PGSQL.5432" Missing In Mountain Lion (OS X Server)

I just upgraded my MacMini Server from Lion Server to Mountain Lion using OS X Server. I am having the same problem with PostgreSQL that I did last year when I first installed Lion Server.
When I try to do any kind of PostgreSQL terminal command I get the following notorious error message that many have gotten over the years:
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
I was attempting to change the password for _postgres when I got the error. I tried several commands but got the same error. I just rebooted my server but no luck. I logged in as root to look at /var/pgsql_socket and the folder is empty. Folder /var/pgsql_socket_alt is also empty.
I have checked online about this. However just about all of the solutions I have read, including on Stack Overflow, suggest a removal and reinstall of PostgreSQL. I do not know but this does not seem like a plausible option because several options on the Server App use PostgreSQL. I contacted Apple Enterprise Support (no agreement) and I was told that my issue would have to be solved by the developers which would cost $695.
I have a website that is down right now because I cannot rebuild it. I don't know where to turn for help with this at this point. I will continue looking online to see if I can find something. However I hope that someone can give me an answer quick so I can rebuild my database.
Update: 12/13/2012 15:33 GMT-6
Here is my output for ps auwx|grep postg:
_postgres 28123 0.0 0.1 2479696 7724 ?? Ss 3:01PM 0:00.04 /Applications/Server.app/Contents/ServerRoot/usr/bin/postgres_real -D /Library/Server/PostgreSQL For Server Services/Data -c listen_addresses= -c log_connections=on -c log_directory=/Library/Logs/PostgreSQL -c log_filename=PostgreSQL_Server_Services.log -c log_line_prefix=%t -c log_lock_waits=on -c log_statement=ddl -c logging_collector=on -c unix_socket_directory=/Library/Server/PostgreSQL For Server Services/Socket -c unix_socket_group=_postgres -c unix_socket_permissions=0770
server1 28216 0.0 0.0 2432768 620 s000 R+ 3:02PM 0:00.00 grep postg
_postgres 28138 0.0 0.0 2439388 752 ?? Ss 3:01PM 0:00.01 postgres: stats collector process
_postgres 28137 0.0 0.0 2479828 1968 ?? Ss 3:01PM 0:00.00 postgres: autovacuum launcher process
_postgres 28136 0.0 0.0 2479696 544 ?? Ss 3:01PM 0:00.00 postgres: wal writer process
_postgres 28135 0.0 0.0 2479696 732 ?? Ss 3:01PM 0:00.01 postgres: writer process
_postgres 28134 0.0 0.0 2479696 592 ?? Ss 3:01PM 0:00.00 postgres: checkpointer process
_postgres 28131 0.0 0.0 2439388 368 ?? Ss 3:01PM 0:00.00 postgres: logger process
Update: 12/13/2012 18:10 GMT-6
After intense web searching this video was found. I was able to get PostgreSQL working and remove the error. I am able to connect using pgadmin and phppgadmin. I was about to go back to Lion Server because of sheer frustration. Now I will not have to.
http://www.youtube.com/watch?v=y1c7WFMMkZ4
I was able to add the following to my .bash_profile to prevent the error:
export PGHOST=localhost
This works because:
If you omit the host name, psql will connect via a Unix-domain socket to a server on the local host, or via TCP/IP to localhost on machines that don't have Unix-domain sockets.
Your OS supports Unix domain sockets, but PostgreSQL's Unix socket that psql needs either doesn't exist or is in a different location than it expects.
Specifying a hostname explicitly as localhost forces psql to use TCP/IP. Setting an environment variable PGHOST is one of the ways to achieve that. It's documented in psql's manual.
Try paste in console this:
$ mkdir /var/pgsql_socket/
$ ln -s /private/tmp/.s.PGSQL.5432 /var/pgsql_socket/
I was able to solve by simply filling in 127.0.0.1 for the PostgreSQL host address rather than leaving it blank. (Django Example)
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'database_name',
'USER': 'database_user',
'PASSWORD': 'pass',
'HOST': '127.0.0.1',
'PORT': '',
}
}
Open 'postgresql.conf' in you favourite editor. Look for the variable 'unix_socket_directories', it will most likely look like this:
unix_socket_directories = '/private/tmp/'
Change the line to this:
unix_socket_directories = '/var/pgsql_socket/'
Note if you want the socket files in more than one directory comma separate them.
A much more simple solution (thanks to http://daniel.fone.net.nz/blog/2014/12/01/fixing-connection-errors-after-upgrading-postgres/) . I had upgraded to postgres 9.4. In my case, all I needed to do (after a day of googling and not succeeding)
gem uninstall pg
gem uninstall activerecord-postgresql-adapter
bundle install
Restart webrick, and done!
As mentioned by others in the comments, a really simple solution to this issue is to declare the database 'host' within the database configuration. Adding this answer just to make it a little more clear for anyone reading this.
In a Ruby on Rails app for example, edit /config/database.yml:
development:
adapter: postgresql
encoding: unicode
database: database_name
pool: 5
host: localhost
Note: the last line added to specify the host. Prior to updating to Yosemite I never needed to specify the host in this way.
Hope this helps someone.
Cheers
Check for the status of the database:
service postgresql status
If the database is not running, start the db:
sudo service postgresql start
Can you check your postgresql.conf file ??
On what port your postgres is running ??
I think it is not running on port 5432.If not change it to 5432
OR on terminal use
psql -U postgres -p YOUR_PORT_NUMBER database_name
I had this problem with Django.
Fix it by explicitly setting your hostname to "localhost".
i make in word by doing this:
dpkg-reconfigure locales
and choose your preferred locales
pg_createcluster 9.5 main --start
(9.5 is my version of postgresql)
/etc/init.d/postgresql start
and then it word!
sudo su - postgres
psql
For RubyOnRails app add localhost
If you use custom Postgresql version
# config/database.yml
default: &default
host: localhost
If you have the above problem but you have upgraded from Yosemite, then a different approach is needed as the upgrade solution can destroy some files. More details are at `pg_tblspc` missing after installation of latest version of OS X (Yosemite or El Capitan).
File permissions are restrictive on the Postgres db owned by the Mac OS. These permissions are reset after reboot, or restart of Postgres: e.g. serveradmin start postgres.
So, temporarily reset the permissions or ownership:
sudo chmod o+rwx /var/pgsql_socket/.s.PGSQL.5432
sudo chown "webUser" /var/pgsql_socket/.s.PGSQL.5432
Permissions resetting is not secure, so install a version of the db that you own for a solution.
apt-get install postgres-xc-client
apt-get install postgres-xc
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket"/var/pgsql_socket/.s.PGSQL.5432"?
I kept on getting the above error and none of the above solutions worked for me. Finally the following solution solved my problem on Mac OS X
Install postgres using brew
brew install postgres
Install brew services
brew tap homebrew/services
To start postgres as a background service
brew services start postgresql
To stop postgres manually
brew services stop postgresql
We can also use brew services to restart Postgres
brew services restart postgresql
First remove the installed postgres:
sudo apt-get purge postgr*
sudo apt-get autoremove
Then install 'synaptic':
sudo apt-get install synaptic
sudo apt-get update
Then install Postgres
sudo apt-get install postgresql postgresql-contrib
check the postgres server is running with following code
sudo service postgresql status
if the postgres server is inactive, write the following command.
sudo service postgresql start
I got this error after my computer froze and rebooted on its own. The solution for me was not found on this page, rather on another very highly rated SO question with the same error psql: could not connect to server: No such file or directory (Mac OS X). The answer: just delete this file /usr/local/var/postgres/postmaster.pid, then brew services restart postgresql did the trick. Heed the warning on the linked answer about killing postgres processes before doing this else you could corrupt your db permanently.
It took me a while but I was able to get this working finally after going through the suggestions offered and additional web searches being done. I used the information in the following YouTube video created by Mactasia:
http://www.youtube.com/watch?v=y1c7WFMMkZ4
When I did this I saw the file with .lock as the extension. However I still got the error when I tried to start the Rails Server when I resumed working on my Rails application using PostgreSQL. This time I got a permission denied error. This is when I remembered that not only did I have to change listen_addresses in the plist but I also had to change unit_socket_permissions to 0777. I also logged in as root to change the permissions on the var/pgsql_socket folder where I could access it at the user level. Postgres is working fine now. I am in the process of reloading my data from my SQL backup.
What I did not understand was that when I had wiki turned on PostgreSQL was supposedly working when I did a sudo serveradmin fullstatus postgres but I still got the error. Oh well.
I just created a new cluster and that worked for me, I was using (PostgreSQL) 9.3.20:
sudo pg_createcluster 9.3 main --start

could not start pgAgent due to log on failure

I wanted to install pgAgent service on windows. Though it installs alright using the following command:
C:\Program Files (x86)\pgAdmin III\1.14>pgagent.exe INSTALL pgAgent -l2 -u postgres hostaddr=localhost port=5432 dbname=postgres user=postgres
the service does not start giving an error: Windows could not start pgAgent service on the local computer. Error 1069: The service did not start due to a logon failure.
The password is being provided using pgpass.conf file. The same password is being used by pgAdmin to logon to databases.
I have even tried by providing same password (as pgpass.conf) using -p option on the command line itself. It did not work either but error is different. On command line it says service could not be started. Service reported no error . However when I see logs in Control Panel/EventViewer following warning is shown:
Couldn't create the primary connection (attempt 10): fe_sendauth: no password supplied
and then an error:
Stopping pgAgent: Couldn't establish the primary connection with the database server.
If it could help, I downloaded pgAgent separately and placed pgAgent.exe in pgAdmin III/1.14 folder where libpq.dll also resides. I am using PostgreSQL 9.0, pgAdmin 1.14 and pgAgent 3.0.0
Can somebody please help me with this?
Go to pgAgent installation folder on windows and execute
C:\Program Files (x86)\pgAgent\bin>pgagent REMOVE pgAgent
This will remove the existing misconfigured windows service
then reinstall the service in the following way giving the password credentials properly. The first -u gives the postgres user created on windows and the second username in the connection string is the db username.
After doing the below start the service and check the Event Viewer if you still see the error.
C:\Program Files (x86)\pgAgent\bin>pgagent --help
Usage:
pgagent REMOVE <serviceName>
pgagent INSTALL <serviceName> [options] <connect-string>
pgagent DEBUG [options] <connect-string>
options:
-u <user or DOMAIN\user>
-p <password>
-d <displayname>
-t <poll time interval in seconds (default 10)>
-r <retry period after connection abort in seconds (>=10, default 30)>
-l <logging verbosity (ERROR=0, WARNING=1, DEBUG=2, default 0)>
C:\Program Files (x86)\pgAgent\bin>pgagent INSTALL pgAgent -u postgres -p admin
-l 2 hostaddr=127.0.0.1 port=5433 user=postgres dbname=first password=admin
ok guys, i am able to solve the issue, by reinstalling PostgreSQL and then installing pgAgent with StackBuilder.