0
votes

Hello I'm trying to use postgresql, on my digital ocean provided server.
I did $ sudo apt-get install postgresql then $ sudo su postgres then $ createuser -P djangousr but then now I get an 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"?

I googled around but just couldn't find a solution. any help would be appreciated

2
Does sudo service postgresql start help?Alex Morozov
@AlexMorozov it asks for postgresql password but I never set any password that It\s [sudo] password for postgres: Sorry, try again.mike braa
Try running dpkg-reconfigure postgresql, your configuration seems to be broken somehow .Alex Morozov
@AlexMorozov it returns locale: Cannot set LC_ALL to default locale: No such file or directory /usr/sbin/dpkg-reconfigure must be run as rootmike braa

2 Answers

0
votes

Once you install the server, you have to configure it - it should have prompted to configure it for you. If it didn't, run the following command to reset the installation:

sudo apt-get update
sudo apt-get remove --purge postgresql
sudo apt-get install postgresql postgresql-contrib

Once they finish, then follow this tutorial. To test if everything is working, the following commands should get you to the postgresql shell:

sudo -i -u postgres
psql

Use \q to quit the shell.

0
votes

I've run into this error, too. Try this command

ln -s /tmp/.s.PGSQL.5432 /var/run/postgresql/.s.PGSQL.5432

This worked out for me... Hope that helps!