Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am working in a RedHat 5 environment. I have the psql command, but am not sure what I need to do to make a database. My admin would probably be willing to put reasonable things on the computer, but ideally I'd like to be able to manage my own little databases on the side.

Information on how to make the database, and what is necessary to do so, would be greatly appreciated!

share|improve this question

migrated from stackoverflow.com Jun 12 '11 at 14:11

This question came from our site for professional and enthusiast programmers.

    
To clarify: there is no postgres instance running (this is where looking things up is difficult). Assume I am a user on a more or less clean linux install. I do have the psql and createdb command, but I want a local instance of postgres on which to use them I suppose. –  A Question Asker Jun 9 '11 at 19:00
add comment

3 Answers

The simplest way to create a database is to issue the createdb command from your (bash?) prompt:

$ createdb mydatabasename

The man page for createdb should have more details.

This, of course, assumes that you have the appropriate database privileges.

share|improve this answer
add comment

You need create database privileges to do so. If you do:

psql -U postgres

And then:

create user foo with login;
create database bar owner foo;
\q

And finally:

psql -U foo bar

If you cannot create a database from lack of permissions, you might want to look into creating a schema as a workaround.

share|improve this answer
add comment

Set up your own instance:

initdb -D ~/pgdata
postgres -D ~/pgdata --port=55555

You can tweak this a little to start automatically or in the background. See the documentation.

Then you can connect:

psql -d postgres -p 55555    
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.