psql: could not connect to server: No such file or directory on Windows - windows

When I try to connect to my postgresql database with psql I receive the error message:
D:\>psql -U postgres
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.5112"?
A similar error I get when using createdb:
createdb: could not connect to database template1: could not connect to server: No such file or directory
next two lines are identical to the psql error.
I can start pgadminIII without problems and access my databases. when I check the properties of the connection it uses port 5432. When using process explorer I see about 5 postgresql processes, though none accessing port 5432. The solutions I found in this forum are about linux/osx platforms, which I am not able to translate into a windows solution.
Could anybody tell what is wrong/what I am doing wrong and suggest a solution?
Thanks for your time.

Related

PG::ConnectionBad upgrade to Yosemite and postgresql 9.4.4

I just updated my mac OS X to Yosemite, version 10.10.4, and postgresql to: psql (PostgreSQL) 9.4.4.
After running rake db:migrate on my Rails 4.2.1 application, my terminal session is responding with:
rake aborted!
PG::ConnectionBad: could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
Simply entering psql in my terminal session also appears a bit off:
$ psql
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"?
After printing out the logs from, cat /usr/local/var/postgres/server.log, I read:
DETAIL: The data directory was initialized by PostgreSQL version 9.3, which is not compatible with this version 9.4.4.
LOG: skipping missing configuration file "/usr/local/var/postgres/postgresql.auto.conf"
FATAL: database files are incompatible with server
I found this answer on SO, but I a hesitant to just start creating a bunch of directories unless that's really what I am suppose to do. I also found an older answer but am not too sure if it's the one to follow.
This SO answer suggests that I remove a, /usr/local/var/postgres/postmaster.pid, but I do not have one, I have a, /usr/local/var/postgres/postmaster.opts -- should I remove the postmaster.opts?
There appears to be lots of advice, but I am not too sure what to follow. Can someone offer some advice in getting my postgresql database running on my rails application?
You could upgrade the database by following an official guide:
brew switch postgres 9.3 # presuming you already installed 9.4.4
pg_dumpall > outputfile
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
mv /usr/local/var/postgres /usr/local/var/postgres.old
brew switch postgres 9.4.4
initdb -D /usr/local/var/postgres
psql -d postgres -f outputfile
PostgreSQL upgrade
Basically, I had to drop and recreate my own database and re-seed it with remote staging data. What I did not understand is that the problem with updating a database is that the data itself also needs to be 'updated' in a way. The data was compatible with a different version

How can I solve "Got minus one from a read call" in oracle sql developer?

When I run the sql developer and set the all data,click the connect but i get this error:
Status : Failure -Test failed: IO Error: Got minus one from a read call
I am beginner in Oracle. How can I solve that error?
I use 64-bit Windows7 and oracle 12c.
In my case the error is connected to a problem about the client's (SQL Developer) ojdbc8 driver and the Oracle 19.3 docker container. The solution for me was to set a system property on the client -- you can do it within the JDBC connection string):
jdbc:oracle:thin:#tcp://host:port/service?oracle.net.disableOob=true
This is the thread that lead me to the answer.
The cause of the error is described here:
https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=357910144923387
You can also solve this problem by dissabling OOB on server side in the sqlnet.ora:
DISABLE_OOB=ON
Another workaround is to use the ojdbc7 driver.
Hope this helps some of us.
From your inputs in the dialog, you are using port 5500. That port is what is used for EM Express. It answers to HTTPs traffic only. So in this case the -1 error message means the protocol negotiation failed. SQLDEV is trying to talk SQL*NET to something listening for HTTPs.
The port you are looking for is 1521 if it wasn't altered. If it was check the $ORACLE_HOME/network/admin/listener.ora for the proper port number.
You need set "tcp.validnode_checking = no" or comment this parameter in sqlnet.ora file then restart listener on db server and test again.
Try it.
I got the same issue but following steps worked for me, it seems Gaurav also has shared it already:
1.Go to the folder where you have installed the database (Like: F:\app)
2.Here you will be able to see many folders, go to product\11.2.0("your databse version")\dbhome_1\NETWORK\ADMIN
3.find listener.ora file and open as text file
4.Check for the port number in that file
5.Now provide that port number while doing connection in sql developer.
Seems you have enabled ACL on the listener.
You can follow these steps to avoid the error:
1. Go to directory $ORACLE_HOME/network/admin
2. Modify sqlnet.ora file with following parameter:
tcp.validnode_checking = no
3. If you don't want to disable this, you can put the machine names as follows:
tcp.invited_nodes=(machine1, machine2)
3. Bounce the listener.
Hope that helps
Ensure the DB is up and running and you can connect locally AS SYSDBA to the database using Oracle binaries owner (usually oracle:oinstall Unix / Linux user). If it does not work, probably you encounter a different problem.
Check privileges of an Oracle file on Unix / Linux host where database is running:
cd $ORACLE_HOME/bin
ls -ltr oracle
-rwxr-xr-x 1 oracle oinstall 136803483 Mar 16 20:32 oracle
Change permissions as below:
chmod 6751 oracle
ls -ltr oracle
-rwsr-s--x 1 oracle oinstall 136803483 Mar 16 20:32 oracle
Most of the answers out there for this problem point to using the wrong PORT number in your connection options, or similar. In my case, after a couple hours of searching, the reason showed to be something else.
Mind which user you are using when starting Oracle listener. You should do it with the oracle user, not as root. Otherwise you end up with listener files being created as e.g. user deamon group root instead of user oracle group dba. This in turn leads to:
TNS-12555: TNS:permission denied
TNS-12560: TNS:protocol adapter error
TNS-00525: Insufficient privilege for operation
Linux Error: 1: Operation not permitted
To check whether this is the case, go to
/var/tmp/.oracle
and list all files (ls -la). If you find out some of the s#* files being created by a root-group user, stop the listener (lsnrctl stop), delete the above files as root and restart the listener as oracle user.
Unfortunately sqldeveloper doesn't show the full stack-trace when reading "Got minus one from a read call". I could find the problem thanks to switching to SQL-Squirrel.
In my case, I was given wrong host and port. I typed "tnsping yourServiceName" in command line in window 10. It returns a different host and port, then I used the correct one in sql developer and it worked.
In my case, it happened when I was using Docker with Oracle 19C.
The workaround is to find the listener.ora file, change 'PORT' and restart the container, ORACLE DB, listener.
It is presumed to be an error that occurred when the host tried to access TCP because it was already LISENT (HOST) by another process.
(When accessing Docker, consider that in most cases, you are accessing localhost.)
I changed the port to 1523, and all the problems were solved.
Try to do what the link , or check listener directory permission, or use command /dbhome/bin/relink all
Try
Connection name: HR_ORCL
Username: HR ,
Password: hr ,
Connection type : local,
Role: SYSDBA
Click on connect.
It will work.
Actually, It is not database specific issue. it is related to port value generated by database during your installation. To overcome on this issue, please follow below.
Go to the folder where you have installed the database (Like: F:\app)
Here you will be able to see many folders, go to product\11.2.0("your databse version")\dbhome_1\NETWORK\ADMIN
find listener.ora file and open as text file
Check for the port number in that file
Now provide that port number while doing connection in sql developer.
Hope it will resolve your issue.

Use same mongodb database over Windows 7 & Ubuntu

I would like to use the same MongoDB database I use on windows 7 as I do on Ubuntu.
On Ubuntu, I went into the file: /etc/mongodb.conf
and changed dbpath=/var/lib/mongodb to dbpath=/media/meaniostack/OS/data/db which is the database on the windows partition.
When I tried starting up mongod & mongo, I got the following error:
MongoDB shell version: 2.6.7
connecting to: test
2015-01-30T14:19:11.027-0500 warning: Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2015-01-30T14:19:11.028-0500 Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed at src/mongo/shell/mongo.js:146
exception: connect failed
However, when I go back to dbpath=/var/lib/mongodb, it works like normal. Keep in mind, that I have mounted media/meaniostack/OS
How do I make this work, and is it possible? Does mongodb, use a different type of storage compared to the one in Ubuntu?
After a bit of messing around I found the solution to be:
Alter permissions to the folders that the database is in.
Change the mongodb.conf path variable
Use mongod --dbpath /media/meaniostack/OS/data/db instead of: service mongod start
Hope this helped anyone with a similar issue.

Connect to Postgres on Mac osX

Part of an install includes a postgres database install. The database is running and the App that uses it is connecting fine.
I want to use the postgres install for some of my own reporting needs. I've got a fair way to getting to the database but I am stumped at the last bit.
I can do a psql -h /path/to/socket but get
psql: FATAL: authentication failed for user "postgres": invalid authentication method.
I have gone in to the pg_hba.conf and the only lines not commented are:
local all all trust
host all all 127.0.0.1/32 trust
host all all ::1/128 trust
As far as I can see this should mean any local attempt at connection would be trusted and therefore OK.
I've tried with specifying different users (root, me, etc) and always get the same reply. Any ideas how I can access the server?

PostgreSQL first time install and attempt to connect

I just installed postgresql-9.1.4-1-windows-x64 on a Windows 7 64 bit machine. I'm having trouble starting the service and connecting to a database.
After a successful installation I've tried the following based on similar postings.
1) Looked for "Start Server" under Start > All Programs > PostreSQL 9.1 and could not find it.
2) Tried starting the server from the command line
pg_ctl.exe -D "C:\Program Files\PostgreSQL\9.1\bin\data"
This gave me the error:
could not create lock file 'postmaster.pid': Permission denied
I have administrative rights, and there is not postmaster.pid file either in the bin or data directories.
3) Next I tried starting the Service from Admistrative Tools by right clicking on the postgresql-9.1.4-1-windows-x64 Service and selecting Start. I received the message:
The postgresql-9.1.4-1-windows-x64 Service on local computer started
and stopped. Some services stop automatically if they are not in use
by other services or programs.
The Event Viewer showed the error as Timed out waiting for server startup
4) I figured there the data in the data directory was probably and initial database, but just in case I ran "initdb" and got:
If you want to create a new database system either remove or empty the
directory c:\program files\postgreSql/9.1/data or run initdb with an
argument other than c:\program files\postgreSql/9.1/data
4) And just for fun I Started pgAdminIII, right clicked on "PostreSQL 9.1(localhost:5432)", selected Connect, entered password, and got:
could not connect to server: Connection refused (0x0000274D/10061) Is
the server running on host "localhost" (::1) and accepting TCP/IP
connections on port 5432?
Does anybody have a suggestion?
Thanks.
«"could not create lock file 'postmaster.pid': Permission denied"»
Do not look any further, Postgres cannot start if it can't create this temp file. If it is not created, you evidently cannot find it if you look for it on the disk. Your DATA directory has been created so no need to re run initdb again and if you try to use pgadmin it complains that it cannot connect to Pg -- which is not running.
I am not familiar with windows but found out where postmaster.pid is to be created you will probably find out why Postgres cannot create this file.
Hope it helps.

Resources