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
Related
I have a Laravel application running on Google Compute Engine instance. I have configured it to connect to a Cloud SQL database Instance, when I SSH to the VM and run php artisan migrate everything runs smoothly. But when I open the application in a browser I get this Error SQLSTATE[HY000] [2002] Permission denied I cant figure out what is going wrong here, I have tried cloud sql proxy but still the application cant establish a DB connection when accessed from a browser. Can anyone figure out the cause of this weird behavior.
I solved this by enabling httpd_can_network_connect_db flag in selinux by running this command.
sudo setsebool -P httpd_can_network_connect_db=1
I also faced another issue with SELinux with redis and solved it by running this command.
sudo semanage port -m -t http_port_t -p tcp 6379
I've setup a new Linux Subsystem (Ubuntu) on Windows to run Ruby scripts, but the PG gem cannot connect to my PostgreSQL server. It seems like I can connect just fine using psql in the terminal (I think), but not using irb.
Problem:
If I run the following in IRB (within the Linux subsystem shell):
require 'pg'
PG.connect(:dbname=>"postgres")
I get the following error:
PG::ConnectionBad: could not connect to server: No such file or directory
Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
However, if I use psql to to select the version(), it returns that just fine:
psql -p 5432 -h localhost -U postgres
postgres=# select version();
Returns:
PostgreSQL 10.1 on x86_64-pc-mingw64, compiled by gcc.exe (Rev5, Built by MSYS2 project) 4.9.2, 64-bit (1 row)
I should mention that I installed Postgres in my Windows environment, and not within the Linux subsystem - however, due to limitations in the subsystem, this seems to be the only way to do it from what I've read online.
I'm not sure if this belongs here or on Superuser or the unix/ubuntu SE, but my basic troubleshooting indicates that this is a problem with Ruby/pg gem, not the subsystem, so I'm posting my question here first.
The default connection is UNIX socket (a quasi-file, as you can see by the error message, /var/run/postgresql/.s.PGSQL.5432), not TCP socket (host:port). Pass your host/port explicitly to PG.connect.
PG.connect(dbname: "postgres", host: 'localhost', port: 5432)
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.
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.
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.