Thread: getting started with psql
Hi,
I have little programming experience and I've been trying to go through the PostgreSQL 9.0.4 documentation tutorial. I got to section about creating a new database and was lost.
On opening psql, get the following prompts:
Server [localhost]:
Database [postgres]:
Port [5432]:
Username [postgres]:
Password for user username:
I have no idea what I should be entering here. I'm not trying to connect to any other server. I'm just trying to create a database for others to connect to. What do I enter for Port? I don't remember signing up for any username. Where do I find my username?
Thanks,
Eric
Hello,
> I have little programming experience and I've been trying to go
> through the PostgreSQL 9.0.4 documentation tutorial. I got to
> section about creating a new database and was lost.
>
> On opening psql, get the following prompts:
> Server [localhost]:
> Database [postgres]:
> Port [5432]:
> Username [postgres]:
> Password for user username:
>
> I have no idea what I should be entering here. I'm not trying to
> connect to any other server. I'm just trying to create a database
> for others to connect to. What do I enter for Port? I don't
> remember signing up for any username. Where do I find my username?
You can always connect to a server and then use the create database command to create a database. If you are keen on not connecting to a server, you could use createdb command from commandline
http://www.postgresql.org/docs/9.0/static/app-createdb.html
But first - have you initialized a db cluster and do you have a PostgreSQL server running? You could find that by running
pg_ctl status
I get the following output..
-bash-3.00$ pg_ctl status
pg_ctl: server is running (PID: 2407)
/usr/local/pgsql/bin/postgres
Regards,
Jayadevan
DISCLAIMER:
"The information in this e-mail and any attachment is intended only for the person to whom it is addressed and may contain confidential and/or privileged material. If you have received this e-mail in error, kindly contact the sender and destroy all copies of the original communication. IBS makes no warranty, express or implied, nor guarantees the accuracy, adequacy or completeness of the information contained in this email or any attachment and is not liable for any errors, defects, omissions, viruses or for resultant loss or damage, if any, direct or indirect."
> I have little programming experience and I've been trying to go
> through the PostgreSQL 9.0.4 documentation tutorial. I got to
> section about creating a new database and was lost.
>
> On opening psql, get the following prompts:
> Server [localhost]:
> Database [postgres]:
> Port [5432]:
> Username [postgres]:
> Password for user username:
>
> I have no idea what I should be entering here. I'm not trying to
> connect to any other server. I'm just trying to create a database
> for others to connect to. What do I enter for Port? I don't
> remember signing up for any username. Where do I find my username?
You can always connect to a server and then use the create database command to create a database. If you are keen on not connecting to a server, you could use createdb command from commandline
http://www.postgresql.org/docs/9.0/static/app-createdb.html
But first - have you initialized a db cluster and do you have a PostgreSQL server running? You could find that by running
pg_ctl status
I get the following output..
-bash-3.00$ pg_ctl status
pg_ctl: server is running (PID: 2407)
/usr/local/pgsql/bin/postgres
Regards,
Jayadevan
DISCLAIMER:
"The information in this e-mail and any attachment is intended only for the person to whom it is addressed and may contain confidential and/or privileged material. If you have received this e-mail in error, kindly contact the sender and destroy all copies of the original communication. IBS makes no warranty, express or implied, nor guarantees the accuracy, adequacy or completeness of the information contained in this email or any attachment and is not liable for any errors, defects, omissions, viruses or for resultant loss or damage, if any, direct or indirect."
Hi On 6 September 2011 03:05, Eric Hulburd <ehulburd@gmail.com> wrote: > Hi, > I have little programming experience and I've been trying to go through the > PostgreSQL 9.0.4 documentation tutorial. I got to section about creating a > new database and was lost. > On opening psql, get the following prompts: > Server [localhost]: > Database [postgres]: > Port [5432]: > Username [postgres]: > Password for user username: > I have no idea what I should be entering here. I'm not trying to connect to > any other server. I'm just trying to create a database for others to > connect to. What do I enter for Port? I don't remember signing up for any > username. Where do I find my username? > Thanks, > Eric OK, there's something you need to understand about how PostgreSQL works. It runs as a server and whatever you need to do with it (e.g. creating a new database) requires connecting to it from a client. The "psql" tool is a client that connects to the database server. Often on the same machine, but not necessarily. If you're on the same machine as the PostgreSQL server (which it seems like you are), "localhost" is the right answer for the hostname. (If you're on Linux/UNIX it would not necessarily be the best option, but I am guessing you're on Windows.) So you should just be able to press Enter, since the default (shown in square brackets) will be used if you just press Enter. The default port for PostgreSQL is 5432 (as you can see in the square brackets) and that is most likely the correct option. You would probably know if you had changed it. The database to connect to depends on the installer to some extent. Some installers will (I believe) create a database called "postgres" automatically. So you could try that. If that fails, you could use "template1" instead, which is a database that's included by default. template1 is used as a template for creating new databases, so normally you should not do anything with it directly, but if there are no other databases yet, you can connect to template1 in order to create new databases. This is because in order to connect to the PostgreSQL server, you always need to specify an existing database to connect to. The usual username for managing PostgreSQL is "postgres". Depending on the installation progress, you might have had to specify the password when it was installing, or else you might not need to specify a password. By the way, if you're unfamiliar with using the command line, one of the GUI administration tools might be easier for you. I have not used them, but other people on this list should be able to help with them if necessary. -- Michael Wood <esiotrot@gmail.com>