reset password
Author Message
victormejia
Posts: 40
Posted 09:50 Oct 05, 2010 |

I had a couple of questions regarding PostgreSQL.  I noticed that I can still log in to the database server using

psql -U postgres

even though I haven't started the server using pgAdmin. Why is that so?

Also, for setting up the csns database, do we create both a csns user and a csns database?  Right now I just created a user "cs520" and once I logged in under cs520 I created the csns database. 

Do I need to have a "cs520" database?

Also I am unsure how to use and populate a PostgreSQL database. In MySQL it was just 

use database_name; and source file.sql

but this doesn't work 

kknaur
Posts: 540
Posted 14:43 Oct 05, 2010 |

Hey Victor,

Running a Script File:
To run a script in PostgreSQL from the command line use this:

psql -f script.sql databaseName

I got it from this website which has some other useful information on it as well:

http://www.petefreitag.com/cheatsheets/postgresql/

For the User Name:
I made a user that was the same name as my logon name for Windows, i.e. whatever name you see when you go to c:\documents and settings\User
This will make it easier when using postgreSQL from the command line because it will automatically default to that user name when you have to type in the password to get into the database.  Otherwise you have to specify which user to type in a password for on the command line.

Database Name:
I just used csns as the name of my database when I created a new one for the csns project.

 

cysun
Posts: 2935
Posted 23:13 Oct 05, 2010 |
victormejia wrote:

I had a couple of questions regarding PostgreSQL.  I noticed that I can still log in to the database server using

psql -U postgres

even though I haven't started the server using pgAdmin. Why is that so?

Also, for setting up the csns database, do we create both a csns user and a csns database?  Right now I just created a user "cs520" and once I logged in under cs520 I created the csns database. 

Do I need to have a "cs520" database?

Also I am unsure how to use and populate a PostgreSQL database. In MySQL it was just 

use database_name; and source file.sql

but this doesn't work 

1. Both psql and pgAdmin are database clients.  The database server is already running no matter which one you use.

2. You don't need a create a csns user.

3. You don't need to create a cs520 database.

4. In psql it's "\c database_name" (like "use database_name" in MySQL) and "\i file.sql" (like "source file.sql"). Read documentation.

Last edited by cysun at 23:14 Oct 05, 2010.
victormejia
Posts: 40
Posted 12:08 Oct 06, 2010 |

Thanks for the help!