LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   QT designer can not connect to postgresql (https://www.linuxquestions.org/questions/programming-9/qt-designer-can-not-connect-to-postgresql-234087/)

raport 09-22-2004 10:18 PM

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.

rjlee 09-24-2004 07:08 PM

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?

raport 09-29-2004 03:52 AM

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.

raport 09-29-2004 03:59 AM

i just don't know how to use the tcip switch (-i) i mean.

thanks again.

rjlee 10-08-2004 07:16 PM

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 user:postgres

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

alejandroye 04-05-2005 11:35 PM

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

rjlee 04-10-2005 09:28 AM

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.

alejandroye 04-11-2005 10:09 PM

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

rjlee 04-12-2005 03:23 PM

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).

alejandroye 04-13-2005 08:32 PM

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:D 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:D

thanks you all and the forum by having this cool tool


All times are GMT -5. The time now is 10:03 PM.