LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 03-21-2022, 01:07 PM   #1
Cameronnoah
Member
 
Registered: Mar 2022
Location: New York City
Distribution: Slackware 15
Posts: 42

Rep: Reputation: 0
Unhappy psql not working


I downloaded the slack builds for pd, pd-sql and postgres and when I Run psql in the terminal I receive:
Code:
bash-5.1# psql
psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directory
	Is the server running locally and accepting connections on that socket?
bash-5.1#
My psql file is as follows:
Code:
bash: /var/lib/pgsql/bin/createdb: No such file or directory
bash-5.1# cd /var
bash-5.1# ls
X11    adm    db     kerberos  lock  mail  named     run    state  www
X11R6  cache  empty  lib       log   man   netatalk  spool  tmp    yp
bash-5.1# 
bash-5.1# cd lib
bash-5.1# ls
AccountsService  elm		   net-snmp   pkgtools	  udisks
NetworkManager	 hp		   nethack    polkit	  udisks2
alsa		 htdig		   nfs	      postfix	  upower
arpd		 iptraf-ng	   ntp	      rootfs-lxc  usb_modeswitch
blueman		 logrotate.status  openldap   rpm	  xdm
bluetooth	 lxc		   openvpn    samba	  xkb
bsdgames	 misc		   os-prober  sddm
dbus		 mlocate	   pgsql      slackpkg
dhcpcd		 mysql		   php	      stunnel
bash-5.1# cd pgsql
bash-5.1# ls
14
bash-5.1# cd 14
bash-5.1# ls
data
Why isn't psql working?
 
Old 03-21-2022, 01:51 PM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,764

Rep: Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931
I've never tried installing postgresql on slackware yet but have you read and followed the READMEs?

Before you can start the server you need to create a postgres user and initialize the database as shown in the setup files.

Now you should be able to start the server.

You also need to add your user to postgresql via create user so it can create databases.

https://slackbuilds.org/repository/1...em/postgresql/

All the postgresql utilities should be linked to /usr/bin.

Last edited by michaelk; 03-21-2022 at 02:06 PM.
 
Old 03-21-2022, 01:54 PM   #3
bassmadrigal
LQ Guru
 
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 8,792

Rep: Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656
Did you see the README.SBo?

It includes:

Code:
Before you can run postgresql you'll need to create the
database files in /var/lib/pgsql. The following should do
the trick.
	# su postgres -c "initdb -D /var/lib/pgsql/14/data --locale=en_US.UTF-8 -A md5 -W"
 
2 members found this post helpful.
Old 03-21-2022, 02:12 PM   #4
Cameronnoah
Member
 
Registered: Mar 2022
Location: New York City
Distribution: Slackware 15
Posts: 42

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by bassmadrigal View Post
Did you see the README.SBo?

It includes:

Code:
Before you can run postgresql you'll need to create the
database files in /var/lib/pgsql. The following should do
the trick.
	# su postgres -c "initdb -D /var/lib/pgsql/14/data --locale=en_US.UTF-8 -A md5 -W"
Code:
bash-5.1$ pg_ctl -D /var/lib/pgsql/14/data -l logfile start
pg_ctl: could not access directory "/var/lib/pgsql/14/data": Permission denied
bash-5.1$ su
Password: 
bash-5.1# pg_ctl -D /var/lib/pgsql/14/data -l logfile start
pg_ctl: cannot be run as root
Please log in (using, e.g., "su") as the (unprivileged) user that will
own the server process.
bash-5.1#
 
Old 03-21-2022, 02:14 PM   #5
khronosschoty
Member
 
Registered: Jul 2008
Distribution: Slackware
Posts: 648
Blog Entries: 2

Rep: Reputation: 514Reputation: 514Reputation: 514Reputation: 514Reputation: 514Reputation: 514
I can confirm if you follow the instructions properly, that postgresql package works well. I've been using postgresql for years and years on Slackware.
 
2 members found this post helpful.
Old 03-21-2022, 05:25 PM   #6
mralk3
Slackware Contributor
 
Registered: May 2015
Distribution: Slackware
Posts: 1,904

Rep: Reputation: 1053Reputation: 1053Reputation: 1053Reputation: 1053Reputation: 1053Reputation: 1053Reputation: 1053Reputation: 1053
Quote:
Originally Posted by khronosschoty View Post
I can confirm if you follow the instructions properly, that postgresql package works well. I've been using postgresql for years and years on Slackware.
Its a great database. I use postgresql with all ruby web applications along with Ruby Sinatra and active record gems.

 
Old 03-21-2022, 07:32 PM   #7
bassmadrigal
LQ Guru
 
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 8,792

Rep: Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656
Quote:
Originally Posted by Cameronnoah View Post
Code:
bash-5.1$ pg_ctl -D /var/lib/pgsql/14/data -l logfile start
pg_ctl: could not access directory "/var/lib/pgsql/14/data": Permission denied
bash-5.1$ su
Password: 
bash-5.1# pg_ctl -D /var/lib/pgsql/14/data -l logfile start
pg_ctl: cannot be run as root
Please log in (using, e.g., "su") as the (unprivileged) user that will
own the server process.
bash-5.1#
Did you miss the su postgres -c part of the command?

It wants you to run the command as the user postgres, which is done by including the red:

Code:
su postgres -c "initdb -D /var/lib/pgsql/14/data --locale=en_US.UTF-8 -A md5 -W"
(Don't miss the closing parenthesis )
 
1 members found this post helpful.
Old 03-22-2022, 10:19 AM   #8
Cameronnoah
Member
 
Registered: Mar 2022
Location: New York City
Distribution: Slackware 15
Posts: 42

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by bassmadrigal View Post
Did you miss the su postgres -c part of the command?

It wants you to run the command as the user postgres, which is done by including the red:

Code:
su postgres -c "initdb -D /var/lib/pgsql/14/data --locale=en_US.UTF-8 -A md5 -W"
(Don't miss the closing parenthesis )
Okay I think I am getting the hang of this. I actually can see and read all of the files that were written in C for nearly all of my programs and psql and that is very interesting. I read the readme and did what it told me to do but now it is asking me for a password. I tried putting in the passwords for both root and the user but it doesn't work. Does psql have a password unto its self and if so how can I figure it out or change it?
 
Old 03-22-2022, 11:56 AM   #9
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,764

Rep: Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931
What password are you referring to and what command are you trying to run? If your trying to run initdb in your last post there isn't a password. Use su or login as root then run the posted command. Since your already root su will not ask for passwords.
 
Old 03-22-2022, 12:20 PM   #10
Cameronnoah
Member
 
Registered: Mar 2022
Location: New York City
Distribution: Slackware 15
Posts: 42

Original Poster
Rep: Reputation: 0
Code:
bash-5.1$ ls
Desktop  Documents  Downloads  Music  Pictures	Public	Templates  Videos
bash-5.1$ cd Documents
bash-5.1$ ls
skeleton
bash-5.1$ cd skeleton
bash-5.1$ ls
Gemfile  Gemfile.lock  data  import_db.sh  lib	spec
bash-5.1$ ./import_db.sh 
Password: 
Password: 
dropdb: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: FATAL:  password authentication failed for user "ace"
Password:
It is saying the password failed for 'ace' which is my user name. I put both passwords for my root and user ace and it failed. I think this is an psql password. How do I figure that out?

Last edited by Cameronnoah; 03-22-2022 at 12:21 PM.
 
Old 03-22-2022, 12:23 PM   #11
mralk3
Slackware Contributor
 
Registered: May 2015
Distribution: Slackware
Posts: 1,904

Rep: Reputation: 1053Reputation: 1053Reputation: 1053Reputation: 1053Reputation: 1053Reputation: 1053Reputation: 1053Reputation: 1053
You need to log in as root on your Slackware system, and then configure the database and its permissions.
 
Old 03-22-2022, 12:29 PM   #12
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,764

Rep: Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931
postgresql passwords are different from user passwords. You need to add the password to your user.

As the postgres user run the command from psql.

ALTER ROLE ace WITH PASSWORD 'my_password';
 
1 members found this post helpful.
Old 03-22-2022, 01:50 PM   #13
Cameronnoah
Member
 
Registered: Mar 2022
Location: New York City
Distribution: Slackware 15
Posts: 42

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by michaelk View Post
postgresql passwords are different from user passwords. You need to add the password to your user.

As the postgres user run the command from psql.

ALTER ROLE ace WITH PASSWORD 'my_password';
Okay I Need to run the command from psql? That is I need to access the psql terminal which requires a password?
 
Old 03-22-2022, 02:52 PM   #14
bassmadrigal
LQ Guru
 
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 8,792

Rep: Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656
Quote:
Originally Posted by Cameronnoah View Post
Okay I Need to run the command from psql? That is I need to access the psql terminal which requires a password?
The system is asking for the password of postgres, which should not have a password set (this is normal). This increases security and requires that you run the su command as root (as root does not need passwords to run as other users).

So, you should be able to get the initial database set up by doing the following:

Code:
su -
<enter root's password>
su postgres -c "initdb -D /var/lib/pgsql/14/data --locale=en_US.UTF-8 -A md5 -W"
In reference to the README.SBo, if you see commands to run preceded by a "#", that is indicating to run the command as root. If you see it preceded by a "$", that indicates you can run it as a normal user. In reference to the command, notice the section I colored red. That is showing to run the command as root.

Code:
Before you can run postgresql you'll need to create the
database files in /var/lib/pgsql. The following should do
the trick.
	# su postgres -c "initdb -D /var/lib/pgsql/14/data --locale=en_US.UTF-8 -A md5 -W"
 
1 members found this post helpful.
Old 03-22-2022, 03:00 PM   #15
Cameronnoah
Member
 
Registered: Mar 2022
Location: New York City
Distribution: Slackware 15
Posts: 42

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by bassmadrigal View Post
The system is asking for the password of postgres, which should not have a password set (this is normal). This increases security and requires that you run the su command as root (as root does not need passwords to run as other users).

So, you should be able to get the initial database set up by doing the following:

Code:
su -
<enter root's password>
su postgres -c "initdb -D /var/lib/pgsql/14/data --locale=en_US.UTF-8 -A md5 -W"
In reference to the README.SBo, if you see commands to run preceded by a "#", that is indicating to run the command as root. If you see it preceded by a "$", that indicates you can run it as a normal user. In reference to the command, notice the section I colored red. That is showing to run the command as root.

Code:
Before you can run postgresql you'll need to create the
database files in /var/lib/pgsql. The following should do
the trick.
	# su postgres -c "initdb -D /var/lib/pgsql/14/data --locale=en_US.UTF-8 -A md5 -W"
Okay will do. I get the following:

Code:
bash-5.1$ su
Password: 
bash-5.1# su postgres -c "initdb -D /var/lib/pgsql/14/data --locale=en_US.UTF-8 -A md5 -W"
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

Enter new superuser password: 
Enter it again: 

initdb: error: directory "/var/lib/pgsql/14/data" exists but is not empty
If you want to create a new database system, either remove or empty
the directory "/var/lib/pgsql/14/data" or run initdb
with an argument other than "/var/lib/pgsql/14/data".
bash-5.1# su postgres -c "initdb -D /var/lib/pgsql/14/data --locale=en_US.UTF-8 -A md5 -W"
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

Enter new superuser password: 
Enter it again: 

initdb: error: directory "/var/lib/pgsql/14/data" exists but is not empty
If you want to create a new database system, either remove or empty
the directory "/var/lib/pgsql/14/data" or run initdb
with an argument other than "/var/lib/pgsql/14/data".
bash-5.1# initb
bash: initb: command not found
bash-5.1# initdb
initdb: error: no data directory specified
You must identify the directory where the data for this database system
will reside.  Do this with either the invocation option -D or the
environment variable PGDATA.
bash-5.1# initdb /var/lib/pgsql/14/data2
initdb: error: cannot be run as root
Please log in (using, e.g., "su") as the (unprivileged) user that will
own the server process.
bash-5.1# su initdb /var/lib/pgsql/14/data2
No passwd entry for user 'initdb'
bash-5.1#
What does this mean?

Then I ran the following:

Code:
bash-5.1# su postgres -c "initdb -D /var/lib/pgsql/14/data2 --locale=en_US.UTF-8 -A md5 -W"
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

Enter new superuser password: 
Enter it again: 

creating directory /var/lib/pgsql/14/data2 ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... America/New_York
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

Success. You can now start the database server using:

    pg_ctl -D /var/lib/pgsql/14/data2 -l logfile start

bash-5.1#
Then I looked if I could run the script:
Code:
bash-5.1$ ls
Desktop  Documents  Downloads  Music  Pictures	Public	Templates  Videos
bash-5.1$ cd Documents
bash-5.1$ l
bash: l: command not found
bash-5.1$ ls
skeleton
bash-5.1$ cd skeleton/
bash-5.1$ ls
Gemfile  Gemfile.lock  data  import_db.sh  lib	spec
bash-5.1$ pg_ctl -D /var/lib/pgsql/14/data2 -l logfile start
pg_ctl: could not access directory "/var/lib/pgsql/14/data2": Permission denied
bash-5.1$ sudo pg_ctl -D /var/lib/pgsql/14/data2 -l logfile start
Password: 
pg_ctl: cannot be run as root
Please log in (using, e.g., "su") as the (unprivileged) user that will
own the server process.
bash-5.1$ ./import_db.sh 
Password: 
Password: 
dropdb: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: FATAL:  password authentication failed for user "ace"
Password:
The scrip merely creates a db:

#!/usr/bin/env sh

dropdb sqlzoo
createdb sqlzoo
psql sqlzoo < data/create_tables.sql

Last edited by Cameronnoah; 03-22-2022 at 03:05 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
psql accented characters not displayed correctly tshikose Linux - Software 2 09-05-2019 02:30 AM
psql FATAL: role "postgres" does not exist error bluethundr *BSD 3 03-20-2012 11:35 AM
Install Psql But Not PostgreSQL? carlosinfl Linux - Software 1 01-05-2012 10:05 AM
psql : command not found. michelle02012007 Linux - Server 1 07-23-2009 07:15 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 02:19 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration