PostgreSQL first time install and attempt to connect - installation

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.

Related

psql: could not connect to server: No such file or directory on 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.

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.

psql: could not connect to server

The error in its entirety reads:
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"?
This is my second time setting up Postgresql via Homebrew on my Mac, and I have no clue what is going on. Previously, it had been working. At some point, I must've entered a command that messed things up. I'm not sure. Now, whenever I enter a SQL command from the command line, I receive the above message. I've run a command to check whether the server is running, and it apparently is not. If I attempt to start the server using
$ postgres -D /usr/local/pgsql/data
I receive the following error:
postgres cannot access the server configuration file
"/usr/local/pgsql/data/postgresql.conf": No such file or directory
I've uninstalled and reinstalled Postgresql via Homebrew, but the problem persists. I'm completely at a loss as to how to get this working. Any help would be appreciated.
your data directory is most likely wrong.
issue a "sudo find / -name "postgresql.conf" " on your terminal to see where your postgres file resides. Then, do an ls in the data directory. Use that in the -D option when starting postgres.

Postgresql is not allowed to be connected remotely

Could someone help take a look this weird problem? I'm still not able to connect remotely to my Postgresql.
My Steps:
Download and install the latest Postgresql to my local machine
Setup postgresql
Create a DB
Modify "pg_hba", add row "host all all 0.0.0.0/0 md5"
Modify "postgresql.conf", make sure "listen_addresses = '*'"
Restart postgresql service
Open local PgAdmin, and connect to DB <-- Success!
From Remote desktop, do the same thing as #7 <-- Failed!
Error Message:
"Server doesn't listen"
"Could not connect to server......accepting TCP/IP connections on port 5432?"
I found "TCP 0.0.0.0:5432 Listening" when I type "netstat -a"
I checked firewall, it's not enabled
......
Can someone please help? Does anyone encounter this situation?
P.S, my os is Winserver 2008
Thanks in advance~
If you're connecting to the local machine via RDP then you'll be connecting via localhost and no firewall or LAN/WAN/NAT settings should affect pgadmin.
When you edit the pg_hba and postgresql.conf files Server 2008 doesn't usually let you edit them directly where they are. I usually copy them out edit them and then paste them back in. You'll need to authorise the paste from an Admin account.
I usually have a separate rule in "pg_hba" with "host all all 127.0.0.1/32 md5" for local connections. Also ensure when you restart the service that it is running under the user "postgres" and not as some other user.

Resources