LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-22-2004, 10:18 PM   #1
raport
Member
 
Registered: Aug 2004
Location: Legazpi City, Philippines
Posts: 77

Rep: Reputation: 15
QT designer can not connect to postgresql


i'm new to linux. i started the postgresql 7.4 server in the root using red hat 9 and it says that Postmaster already running. but when i used QT Designer's database connection, in which i wrote Driver: QPSQL7 database: all user: all, host: localhost a dialog box appears stating: can not connect to the database. please ensure that the database is running and that all the connection information is correct. [QPSQL: unable to connect could not connect to server. connection refused. is the server running on host localhost and accepting TCP/IP connections on port 5432?

i tried to open the pg_hba.conf and postgresql.conf to change the tcip from false to true still the problem persists.

i would appreciate any help on this matter.
 
Old 09-24-2004, 07:08 PM   #2
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,994

Rep: Reputation: 76
The obvious question is did you reload or restart postgresql after changing the config file?

Have you set up a user and a database? Are your username and password correct? Can you log in using the terminal interface?
 
Old 09-29-2004, 03:52 AM   #3
raport
Member
 
Registered: Aug 2004
Location: Legazpi City, Philippines
Posts: 77

Original Poster
Rep: Reputation: 15
The obvious question is did you reload or restart postgresql after changing the config file?

Have you set up a user and a database? Are your username and password correct? Can you log in using the terminal interface?




yes i restarted postgresql and set up a user database. when i used the terminal interface i can open my database.

i followed the procedure/turorial below and successfully got the same result.

Login as user postgres: su - postgres
Initialize PostgreSQL database server: initdb --pgdata=/var/lib/pgsql/data
Starting the database server: As root. (from most to least favorite method)
service postgresql start
Create a database: createdb bedrock
(As Linux user postgres)
Connect to the database: psql bedrock
Execute command as Linux user postgres
You will now be at the PostgreSQL command line prompt...... and so on

i just know how to use the tcip switch -i

thanks again.
 
Old 09-29-2004, 03:59 AM   #4
raport
Member
 
Registered: Aug 2004
Location: Legazpi City, Philippines
Posts: 77

Original Poster
Rep: Reputation: 15
i just don't know how to use the tcip switch (-i) i mean.

thanks again.
 
Old 10-08-2004, 07:16 PM   #5
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,994

Rep: Reputation: 76
In order to connect to the database, you will need to add a Postgresql user for the user who is connecting, and/or set the appropriate username and password in the QSql database information.

I doubt that user:all will work; try userostgres

Also, try running this:
Code:
telnet 127.0.0.1 5432
If you don't get an error message saying that you can't connect to the post, then something is listening on port 5432
 
Old 04-05-2005, 11:35 PM   #6
alejandroye
Member
 
Registered: May 2004
Location: SOUTH FLORIDA USA
Distribution: MANDRIVA / CENTOS
Posts: 146

Rep: Reputation: 15
hello

I installed postgres in my system and was working good until I think the computer crash, after that I can not access to any of the db's that I had

I am trying to reload or stop the db and I get the messages

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"?

Any time that I try to access to the directory where are the data /usr/lib/pgsql/data

say "permission denied" been postgres user, like, I do not have access to my own files

[postgres@localhost root]$ postgres -D /var/lib/pgsql/data
FATAL: could not open configuration file "postgresql.conf": Permission denied

[postgres@localhost root]$ postmaster -D /var/lib/pgsql/data
FATAL: could not read permissions of directory "/var/lib/pgsql/data": Permission denied


anybody can help me???

thanks you
 
Old 04-10-2005, 09:28 AM   #7
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,994

Rep: Reputation: 76
alejandroye; this in an unrelated question and it should have gone in a different thread.

Having been after a crash, this sounds like it may be a filesystem problem — but it's hard to tell at this point. First look at the owner and permissions of the directories, to see if root and postgres can actually read these files:
Code:
ls -ld /var/lib/pgsql/data
Also, do you mount /var, /var/lib or /var/lib/pgsql as a seperate partition? If you do, then they will be listed in a line in the /etc/fstab file.
Code:
sudo -c 'cat /etc/fstab'
If these directories are mounted seperately, run
Code:
cat /proc/mounts
and check if they are actually mounted.
 
Old 04-11-2005, 10:09 PM   #8
alejandroye
Member
 
Registered: May 2004
Location: SOUTH FLORIDA USA
Distribution: MANDRIVA / CENTOS
Posts: 146

Rep: Reputation: 15
thank you for you help

I did not mean crash, sorry, I just was trying to install a those free forum script in PHP and SQL(postgres) and when I tried to run I got the message

pg_pconnect(): Unable to connect to PostgreSQL server: could not connect to server: Connection refused Is the server running on host "localhost" and accepting TCP/IP connections on port 5432?

so, I tried to see the db and I couldn't, I tried to access as root, postgres and nothing happened

also I tried to stop postgres with the line:

[root@localhost root]# pg_ctl -D /var/lib/pgsql/data stop

and I got the message


/usr/bin/pg_ctl: line 274: kill: (3762) - No such process
waiting for postmaster to shut down................................................................ failed
pg_ctl: postmaster does not shut down


after that I tried to start, being root and show me this

[root@localhost root]# pg_ctl -D /var/lib/pgsql/data start
pg_ctl: Another postmaster may be running. Trying to start postmaster anyway.
"root" execution of the PostgreSQL server is not permitted.
The server must be started under an unprivileged user ID to prevent
possible system security compromise. See the documentation for
more information on how to properly start the server.
pg_ctl: cannot start postmaster
Examine the log output.

I loged as postgres and I tried again

[postgres@localhost root]$ pg_ctl -D /var/lib/pgsql/data start
FATAL: could not read permissions of directory "/var/lib/pgsql/data": Permission denied
postmaster successfully started

and I suppose to get access, because I already start the db like that from the begining and was working good, was after I tried to install the script
PD: I am sure is not a virus or something like that because the same script is working in other servers of friend of mine

rjlee:
I tried the line that you told me:ls -ld /var/lib/pgsql/data
and of course I can see all the files being postgres or root accessed


any help I really appreciate

ale
 
Old 04-12-2005, 03:23 PM   #9
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,994

Rep: Reputation: 76
Quote:
Originally posted by alejandroye
pg_pconnect(): Unable to connect to PostgreSQL server: could not connect to server: Connection refused Is the server running on host "localhost" and accepting TCP/IP connections on port 5432?
PostgreSQL supports two methods of connection: TCP/IP sockets and UNIX-domain sockets. This is controlled by the option tcpip_socket. This is off by default, so you probably need to turn this on. See the postgresql manual.

Quote:
/usr/bin/pg_ctl: line 274: kill: (3762) - No such process
waiting for postmaster to shut down................................................................ failed
pg_ctl: postmaster does not shut down
This sounds like a stale lockfile, which usually means that the system was rebooted without going through init.d since the server was last started.

Quote:
[postgres@localhost root]$ pg_ctl -D /var/lib/pgsql/data start
FATAL: could not read permissions of directory "/var/lib/pgsql/data": Permission denied
postmaster successfully started

and I suppose to get access, because I already start the db like that from the begining and was working good, was after I tried to install the script
Quote:
PD: I am sure is not a virus or something like that because the same script is working in other servers of friend of mine
It is highly unlikely that you have a virus; it's much more likely to be a difference in configuration, or possibly a different version, that is causing the problem.

Quote:
rjlee:
I tried the line that you told me:ls -ld /var/lib/pgsql/data
and of course I can see all the files being postgres or root accessed
This line should give you the entry for the directory; did you perhaps append a slash (/) to the end of the command? You may need to be able to create or delete files (write-access to the directory) as well as just being able to read them (read and execute access to the directory).
 
Old 04-13-2005, 08:32 PM   #10
alejandroye
Member
 
Registered: May 2004
Location: SOUTH FLORIDA USA
Distribution: MANDRIVA / CENTOS
Posts: 146

Rep: Reputation: 15
Ok, thank you very much about your help rjlee


But I fixed the problem that took me 1 week solved, I will post here to help persons like me that are not still guru in this area so, it will help anyway


My server were working good, I could access, creater, modify and delete tables, db's and more, actually I had 4 db's that I was working

Some day I dicide to install the free forum downloaded from internet (http://www.funkboard.co.uk) and suddenly I could access to my db's and I start postting help in any forum that I found aboud this

so the simple solution about this were that the owner of all directories and files were change and the group it keep the same(postgres)

I got:
drwx------ 9 78 postgres 4096 Apr 4 22:14 base/
drwx------ 2 78 postgres 4096 Apr 12 16:36 global/
drwx------ 2 78 postgres 4096 Oct 20 12:48 pg_clog/
-rw------- 1 78 postgres 3533 Apr 5 22:11 pg_hba.conf
-rw------- 1 78 postgres 1441 Oct 20 12:47 pg_ident.conf
-rw------- 1 78 postgres 4 Oct 20 12:47 PG_VERSION
drwx------ 2 78 postgres 4096 Mar 21 21:35 pg_xlog/
-rw------- 1 78 postgres 7815 Apr 6 00:30 postgresql.conf
-rw------- 1 78 postgres 47 Apr 12 16:34 postmaster.opts
-rw------- 1 78 postgre 45 Apr 12 16:34 postmaster.pid

so, instead having owner postgres I was having 78, so I just change with

# chown postgres -R /var/lib/pgsql

and NOW is working, what happy I am now

thanks you all and the forum by having this cool tool

Last edited by alejandroye; 04-13-2005 at 08:36 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
QT Designer can not connect to postgresql raport Linux - General 6 09-29-2004 03:18 AM
Embedded SQL -Unable to connect to PostgreSQL database vikram_cvk Linux - Software 1 05-30-2004 06:14 AM
Connect PHP to PostgreSQL (on red-hat 8) Hady Linux - Software 0 05-04-2004 11:53 PM
Postgresql connect to MS Access bartgymnast Linux - General 4 03-24-2003 08:43 AM
Connect to PostgreSQL via PHP RedHatMN Programming 3 12-12-2002 06:03 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:06 AM.

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