Simple question re: PostgreSQL & accessing via PGAdmin

Status
Not open for further replies.

Yaz

Ars Tribunus Angusticlavius
7,006
Subscriptor++
(see my more recent post below for my current problem)

Hi,

I'm simultaneously trying to learn a bunch of new things while getting a Reddit clone running, and I have a few basic questions:

**Answered**
1. I've been told to input the following commands with paster shell to edit some settings:
Code:
sudo paster shell example.ini
>>> from r2.models import Subreddit
>>> for sr in Subreddit._query():
...(four spaces) sr._downs = 1
...(four spaces) sr._commit()
...(I'm stuck here)
What do I need to do at this point to save, run, or otherwise exit the shell?
Solution: Just press enter again.

2. I've been told that I can access stored data and some settings within the database. My PostgreSQL path is: /usr/local/pgsql/data. However, I'm unable to access this path via SFTP, and from SSH, when I try to enter the directory, I get: "-bash: cd: data: Permission denied." How does one go about accessing and modifying records in a database? I'm trying to access it by entering:
Code:
psql -h /usr/local/pgsql/data
or psql -d reddit
Is this the best way to do things, or is there a simpler GUI/other interface that I could use? Thanks for any help you can provide.

3. I'm trying to get AMQP running now.
 
D

Deleted member 43669

Guest
Yaz":2x0owdrd said:
2. I've been told that I can access stored data and some settings within the database. My PostgreSQL path is: /usr/local/pgsql/data. However, I'm unable to access this path via SFTP, and from SSH, when I try to enter the directory, I get: "-bash: cd: data: Permission denied." How does one go about accessing and modifying records in a database? I'm trying to access it by entering:
Code:
psql -h /usr/local/pgsql/data
or psql -d reddit
Is this the best way to do things, or is there a simpler GUI/other interface that I could use? Thanks for any help you can provide.

You should use a tool such as psql to access a Postgres database, however, you are not using the right incantation.

-h specifies a host name, and clearly /usr/local/pgsql/data is not a hostname. You might want to refer to Postgres' psql documentation, for instance: http://www.postgresql.org/docs/8.4/stat ... CONNECTING

However, psql might be a little daunting being a console text-mode application. If you want to use a GUI, you might want to use PgAdmin 3, which is the "official" GUI for Postgres. It needs exactly the same configuration than psql for connecting to the database. However, if you are running Postgres on a remote host and executing psql through ssh on the same remote host, note that running PgAdmin in the computer you are sitting in front of and connecting to a remote host might be more involved than psql + ssh.
 

Yaz

Ars Tribunus Angusticlavius
7,006
Subscriptor++
Thank you for your reply. I realized very quickly that I used the wrong info for the switch.

I'm able to access the database with:
Code:
psql -d dbname -U postgres

Now, you're right--the psql interface is pretty intimidating, but it sounds like this is the way to go, especially for someone who's not familiar with the text-only interface.

Looking at documentation, since I'm going to be running PGadmin III on a different computer, it seems like I'll need to allow the PostgreSQL server to accept outside connections. Within the database's folder, should I edit the postgresql.conf file in there so that:
Code:
listen_addresses = 'localhost' --> listen_addresses='*'

Once I do that, and reboot postgres, it looks like I can connect with the following settings:
Host: (my domain)
Port: 5432
Maintenance db: (my dbname)
Username: postgres
Password: (postgres's password)

Is this on the right track?
 

Yaz

Ars Tribunus Angusticlavius
7,006
Subscriptor++
I'm still having troubles accessing my database with PGAdmin. I want to access the database within path: /usr/local/pgsql/newdata/

Here's what I've done so far:
For the specific database folder that I want to access, I've edited /usr/local/pgsql/newdata/postgresql.conf to contain:
listen_addresses='*'
Within the database folder, I've also edited /usr/local/pgsql/newdata/pg_hba.conf
host all all 0.0.0.0/0 password (or MD5)

I've done: create user yaz with password 'yazpw' (not really my username and password)

Now, I'm still having trouble connecting via PGAdmin with the following settings:
Host: (my domain)
Port: 5432
Maintenance db: (my dbname)
Username: yaz
Password: yazpw

I receive an error: "password authentication failed for user "yaz"

What am I doing wrong? I've tried using the linux username & password for user postgres, making a user postgres within postgres & changing the password. Can someone help?
 
Status
Not open for further replies.