Please, I need help with my postgres server. I have problems starting the server. I was using the app here a few months ago and everything was fine. Today I spent hours trying to start it yet couldn't. I then realised I had another instance of PostgreSQL installed. I uninstalled version 9.6 blocking my app.
Now after trying again, the PostgreSQL app throws the error when I use psql:
FATAL: role "username" does not exist
I didn't set the role or user but it somehow took my username and is throwing does not exist. Please, how do I start my server. I have seen someone with a similar issue here but unlike in his case, I didn't even get to start the server. not to speak of deleting the database. Please, how do I address this? Any help would be appreciated.
I also noticed he was able to execute
which psql
which returned his supposed psql path. It does not return anything in my case. Not sure how the configuration works, this is my second time using this database and it failed right away.
Thank you for your time, as answered in one of the SO question here. Running
sudo -u postgres -i
did give me access to postgres, but if you are using the postgres app like myself here . Running psql commands would not work for you as postgres is not installed globally on your machine. But running
'/Applications/Postgres.app/Contents/Versions/9.5/bin'/psql -p5432
which is the exact command the postgres app execute when you attempt to start the service works great and start the service for me. You can then proceed and add the role and database your postgres app looks for by default. So in summary. Below is what worked for me.
$sudo -u postgres -i
$'/Applications/Postgres.app/Contents/Versions/9.*/bin'/psql -p5432
#CREATE USER postgres SUPERUSER;
#CREATE DATABASE postgres WITH OWNER postgres;
Related
I have successfully installed postgresql and added path to my environment variable in windows 10. But the problem is when i try to run psql postgresql in command prompt it gives error saying
C:\Users\adity>psql postgres
Password for user adity:
psql: error: could not connect to server: FATAL: password authentication failed for user "adity"
I am 100% sure my password is correct I have tried reinstalling and uninstalling many time in case i missed password but every time it gives me same error. Although when i try to run from GUI it starts running. This is frustrating and I am not sure what the problem is.
The database superuser that was created during database cluster creation is very likely called postgres.
So rather than using the default, which is to use the database user whose name is the same as your current operating system user, explicitly specify the database user postgres:
psql -U postgres
I have installed postgres via brew. However, after running rake db:create I get error
role 'posgres' does not exist
I can not run psql as role of my user does not exist, which is logical, but I can not login with -u postgres either.
Any suggestions, how to create postgres user ?
It seems like the service is not running / turned on after instal.
Documentation reference:
https://www.postgresql.org/docs/current/static/server-start.html
Then perform initdb /[data location]
Then you will need to sudo to postgres user (the service user) to issue commands to the database.
I have installed Postgres with Homebrew, and it didn't ask me to setup any username and password. Now I am having troubles connect the ruby project with db. I don't know what username and password to use in config file.
I checked my pg_hba.conf file, all methods are set to trust, and user is mostly set to all or my profile name.
When I start Rails, the server starts and then gives PG::ConnectionBad error.
I am new to Ruby and all this and would appreciate some help.
I am not sure if you checked any docs before posting, default user is postgres, but check if postgres service is running ps aux | grep postgres and follow this doc to perform all required setup. First steps are also worth your attention.
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.
I used blog entry by Robby on Rails site:
http://www.robbyonrails.com/articles/2008/01/22/installing-ruby-on-rails-and-postgresql-on-os-x-third-edition
Got to the end, but when I tried accessing the pg database I was denied.
I've tried to change pg_hba.config file to trust so that I can gain access anyway (without a password), but proved fruitless.
Please help. Thanks in advance.
Restart postgresql after you alter the pg_hba.config file to make sure your changes are read. Next, type
psql -U myUser template1
in a terminal, where myUseris the name of the user running the postgres proces. That should make you log in as administrator. Next, in the psql session, write
ALTER USER realUser PASSWORD 'myNewPassword';
in order to reset the password. Here realUseris the user of the database you are trying to connect to.