Well I am trying for hours to install and configure postgres in ubuntu but getting below 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 almost every solution I found but still no success.
Below are the commands I have used to install postgres:
sudo apt update
sudo apt install postgresql postgresql-contrib
sudo -i -u postgres
psql (After this I got an error)
The error arises during the installation of postgres.Kindly give suggestions or resources through I which I can fix this!
Related
I want to use redis in my nodejs application.I have installed npm package for redis. But while starting application i am getting error as
Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED 127.0.0.1:6379
Install WSL on windows. Can do this through Microsoft store. Example below is using Ubuntu and assumes you have installed the distribution with an open terminal. Ubuntu can be started by normal ways of starting applications on Windows.
> sudo apt-get update
> sudo apt-get upgrade
> sudo apt-get install redis-server
> redis-cli -v
This performs updates to ubuntu on your machine and installs redis.
The last command should output something like: redis-cli 6.2.5
If for some reason redis is not running, execute sudo service redis-server restart in ubuntu terminal
I want to install postgresql in ubuntu but facing lot of issues,searched a lot but still no success,so when I try to install I used below commands:
sudo su -
apt-get install postgresql-9.5
update-rc.d postgresql enable
When the installation completes it gives me the error of
9.5 main 5432 down postgres /var/lib/postgresql/9.5/main /var/log/postgresql/postgresql-9.5-main.log
and after when I give following command
sudo -i -u postgres
psql
it gives me
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"?
How can I fix this?
In Postgres, you need to connect as a specific user called postgres.
Try doing this : sudo -i -u postgres and then use psql
Through some mishap I seem to have 2 separate Postgres servers on my local Ubuntu machine. PGAdmin connects to one (localhost:5432), which can also be reached with the terminal through: sudo -u postgres psql postgres -W -h 127.0.0.1 -p 5432
The other "default" server can be reached through the terminal with just sudo -u postgres psql postgres
For other info, locate bin/psql returns:
/usr/bin/psql
/usr/lib/postgresql/9.5/bin/psql
I suspect the latter of those directories is the Postgres 9.5 instance I really want to use, and the one I want to associate with without needing to specify -h 127.0.0.1 -p 5432. The other can be removed completely. How do I resolve this?
You can use the package manager to remove it.
From terminal, you can list the installed versions of PostgreSQL executing:
$ apt list --installed | grep postgresql
The ones with the format postgresql-X (where "X" is the version) is those to remove. You should be able to do it with the apt purge command.
For example, to remove the version 9.6, you have to execute:
$ sudo apt purge postgresql-9.6
/usr/bin/psql should be a symbolic link to the most recent version installed (/usr/lib/postgresql/9.6/bin/psql).
I have a machine on DigitalOcean running on Ubuntu 16.04 (I used lsb_release -a)
It is a one-click MongoDB machine, but suddenly it stopped working. Trying to resolve it, I tried many things:
service mongod status
rm /var/lib/mongodb/mongod.lock
153 service mongod restart
looking at logs, there was no change... less /var/log/mongodb/mongod.log
There was no result in systemctl list-unit-files | grep mongo
The mongod service was't even listed in sudo service --status-all
My conf less /etc/mongod.conf looked OK, however I noticed there was two database... one at /var/lib/mongodb and another one at /data/db/ like if there had been a migration at some recent point
iptables -L seems fine
I tried mongod --repair but i had still the issue
I made sure the db was owned by the mongo user sudo chown -R mongodb:mongodb db
Then I decided to reinstall mongo-org
sudo apt-get purge mongodb-org*
sudo rm -r /var/log/mongodb
sudo rm -r /var/lib/mongodb
...
sudo apt-get install -y mongodb-org
But still didn't work
So after 2 hours, I still had the same issue after running sudo service mongod start
unable to resolve host MongoDB
Any Idea ?
I finally found out. The main issue wasn't related to MongoDB afterall. Because I had created a DigitalOcean oneclick mongo server, the name of the machine was MongoDB. It was confusing for this debug.
I read this at some point and tried out
https://askubuntu.com/questions/59458/error-message-sudo-unable-to-resolve-host-user
Turns out that in my hosts I was missing the machine name.
when typing less /etc/hostname i read
MongoDB
So i changed sudo nano /etc/hosts
from
127.0.1.1 TEST-MONGO TEST-MONGO
to
127.0.1.1 TEST-MONGO TEST-MONGO MongoDB
And it solved my problem
I installed Postgresql on my virtual machine running ubuntu using the command
sudo apt-get install postgresql-client
Next, I need to set up the connection string, login roles, databases, etc... However, I need to do it in the terminal since I don't have a GUI. Does anyone know how to do this or can point on a tutorial on how to do so??
Thank you in advance!
Follow these command:
Install and Configure Postgres
sudo apt-get install postgresql
This command will install postgres 9.1 by default in ubuntu 14.04 or any debian distribution. if you want to use any specific version of postgres(i.e 9.3, 9.4) you need to update the source list. for example to install postgres-9.4 you can follow below steps.
Create the file /etc/apt/sources.list.d/pgdg.list, and add a line for the repository using vim or nano editor
deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main
Import the repository signing key, and update the package lists
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
and update the packages using
sudo apt-get update
after that you can search/install the available/supported postgres version
sudo apt-get install postgresql-9.4
After installing postgres 9.4, change to the postgres user so we have the necessary privileges to configure the database
sudo su - postgres
Now create a new database user with access to create and drop database.
createuser --createdb --username postgres --no-createrole --no-superuser --pwprompt odoo
Enter password for new role: ********
Enter it again: ********
Finally exit from the postgres user account:
exit
man psql or the official psql docs. Also see the tutorial.
On the server run the commands below.
sudo apt-get update
sudo apt-get install -y postgresql postgresql-contrib
Create a database and a user to access it
I prefer to create one user per database for security.
Replace DATABASE_NAME_HERE and USER_NAME_HERE with the values that you want to use
this will prompt you for a database password
sudo -u postgres createuser -P USER_NAME_HERE
sudo -u postgres createdb -O USER_NAME_HERE DATABASE_NAME_HERE
Test connecting to Postgresql
psql -h localhost -U USER_NAME_HERE DATABASE_NAME_HERE
Postgresql will ask you for your password. Then you should see:
psql (9.3.5)
SSL connection (cipher: DHE-RSA-AES256-SHA, bits: 256)
Type "help" for help.
DATABASE_NAME_HERE=>
To exit type:
\q