Sunday, May 12, 2013

First steps on a new postgresql installation

I've found myself trying postgres over mysql for a few things and had some trouble accessing the db server at all at first. So here's how you first access the server:

$ su -          # su to root
# su - postgres # su to postgres
$ psql          # access the server

That wasn't so hard now was it? Once I'm in the psql shell, I tend to issue the following SQL statement so my primary user has unlimited access, to make things easier for development:

postgres=# CREATE USER my_user SUPERUSER;

And that's all the trouble you need to go trough to get started with postgres.

Now you can just call 'psql' as your primary user and do whatever the hell you like (including destroying all data in the db). Note that, when just calling psql, you'll get an error like 'psql: FATAL: database "my_user" does not exist', so just do 'psql postgres' to get in and create some other database.

No comments:

Post a Comment