postgresql: no such file or directory - postgresql

I'm trying to install a postgresql database on my VPS server by using this guide.
In there it says
sudo apt-get install postgresql postgresql-contrib libpq-dev
And then
sudo su - postgres
createuser --pwprompt
exit
When I run createuser --pwprompt it asks me to create a password, once I fill it in I get the following error:
createuser: could not connect to database postgres: 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"?
If I do psql --version I get psql (PostgreSQL) 9.4beta3
And which psql outputs /usr/bin/psql
Any idea on how to fix this problem?
Update
Running pg_ctl gives another error
WARNING:root:could not open file '/etc/apt/sources.list.d/passenger.list'
The program 'pg_ctl' is currently not installed. To run 'pg_ctl' please ask your administrator to install the package 'postgres-xc'
Althgough reading up on postgres-xc shows quite a lot of other problems.

Related

How do i install Postgres on Ubuntu and create a superuser?

I have successfully installed Postgres on Ubuntu 20.04 by running the following commands:
$ sudo apt-get update
$ sudo apt-get install postgresql postgresql-contrib libpq-dev
which was successful. I then run the command:
$ sudo service postgresql start
which was also successful.
However, the command
$ sudo -u postgres createdb $USER
failed. The error message was as follows:
createuser: error: could not connect to database template1: 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"?
Please help me out.

could not connect to database postgres

createuser: could not connect to database postgres: 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"?
I am trying to install dspace 6.3 on ubuntu server 18.04 but after installing postgresql when I run the command createuser -U postgres -d -A -P dspace I am getting the above error help please
Did you start the server? Try sudo service postgresql restart or sudo systemctl restart postgresql

Postgresql 9.5 on ubuntu

im try install postgresql on ubuntu using this tutorial
https://www.youtube.com/watch?v=dSqosCc_KLA
And im stop on step when print comand psql 4:54 seconds video
psql: 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"?
This is a known issue, I had that too. Try to reinstall postgresql with a version number. Remove your postgres and reinstall it. For example:
sudo apt-get install postgresql-9.5
An other fix would be to create a softlink for example:
ln -s /tmp/pgsql.5432 /var/run/postgresql/pgsql.5432
I would suggest you to reinstall postgresql like I said in point 1.
Note: default port of postgresql is 5432

Unix socket error postgresql 9.4

I just installed postgresql 9.4 on a brand new 15.04 ubuntu install and I'm unable to start the psql server. Every time I try to run sudo -u postgres psql, it gives me the following error:
psql: 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"?
I have tried every single solution posted here and on every other forum, but none have worked except one:
http://ubuntuforums.org/showthread.php?t=869080
sudo mkdir -p /usr/local/pgsql/data
sudo chown -R postgres:postgres /usr/local/pgsql/
sudo sudo su postgres
cd /usr/lib/postgresql/9.4/bin/
./initdb -D /usr/local/pgsql/data
./postgres -D /usr/local/pgsql/data
I tried changing the init.d script as stated there but that doesn't work, and the solution above only seems to work once, after that, a file locks up and I'm unable to run ./postgres -D /usr/local/pgsql/data
Can someone please help? I've tried removing, purging, reinstalling, multiple-versions, etc. Every single time I get the same error.
hanks!
T
psql is not the PostgreSQL server. It is the command-line client that connects to an already-running server.
It looks like you had no PostgreSQL server running, so there was nothing to connect to. Note that the error message says Is the server running...
As you have already noted, to start a PostgreSQL server you need to run postgres -D /path/to/datadir (or preferably something like pg_ctl -D /path/to/datadir -w start -l pgstartup.log).
Rather than doing so manually, you should have your operating system do this automatically when you start up. Most PostgreSQL installers and packages will set this up for you. Some require additional steps to enable it, which will be explained in their documentation. You haven't mentioned how you installed PostgreSQL / from where, so I can't be more specific about this.
If you use the Ubuntu PostgreSQL packages or http://apt.postgresql.org/ packages, they'll register a service for you.
Please see https://help.ubuntu.com/community/PostgreSQL

Fresh PG install on Ubuntu [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I am setting up a Digital Ocean Ubuntu server to host my new site on and having trouble setting up postgres.
I installed it fine but when I try to access it using psql I get:
psql: FATAL: role "demo" does not exist
A few quick questions:
Has installing postgres create an standard ubuntu user account?
How do I create a new postgres account, I have tried createuser but get the following:
demo#dubbo:~$ createuser
Enter name of role to add: demopg
Shall the new role be a superuser? (y/n) y
createuser: could not connect to database postgres: FATAL: role "demo" does not exist
I guess that once I have a postgres user I should then be able to create a db for my application to use.
Here are the steps I use to install PostgreSQL on Ubuntu for development (I'm using PostreSQL with Rails):
$ sudo apt-get install postgresql postgresql-contrib libpq-dev
We need libpq-dev to be able to install the Ruby pg gem. After the setup completes,
then run the following commands:
$ sudo -u postgres createuser --superuser $USER
$ sudo -u postgres createuser --superuser demo
$ sudo -u postgres psql postgres
The first command creates a user that matches your user name. The second command creates a user for your application to use--this is what you will normally login to psql with. The third command will bring you directly into the psql console, and will open up the postgres database. It's just the database corresponding to the postgres user, which for some reason is necessary when installing PostgreSQL.
Once in the psql prompt, type the following command:
postgres=# \password demo
Set the password for your user. Once it returns you to the prompt, type "\q" to exit the psql prompt.
Now you'll be back in your terminal, and you can then create a database for your application.
$ createdb your_db_name
Now, you need to change the postgresql.conf file to make PostgreSQL listen on at least localhost. If you have a setup where you want to listen on an external IP or something, change this line to either the IP or just '*'.
/etc/postgresql/9.1/main/postgresql.conf:
listen_addresses = 'localhost'
Then, in pg_hba.conf, make sure you've got this:
/etc/postgresql/9.1/main/pg_hba.conf:
# "local" is for Unix domain socket connections only
local all all md5
Otherwise you'll probably get an error when trying to login from your Rails app. After this, all you've got to do is simply start PostgreSQL using this command:
$ sudo /etc/init.d/postgresql start
And you're set to go! Start psql with:
$ psql -U demo
You will be prompted for the password you set. You can connect to the database you created with:
# \c your_db_name
Good luck!