psql -U postgres -h localhost#9.2有一个默认的数据库用户就是,当前系统用户。不注意的话就会很讨厌
grant all privileges on database postgres to postgres;
alter user livegamer with superuser;
\du
alter user livegamer with encrypted password 'livegamer';
brew install postres
initdb /usr/local/var/postgres
mkdir -p ~/Library/LaunchAgents
cp /usr/local/Cellar/postgresql/9.0.4/org.postgresql.postgres.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/org.postgresql.postgres.plist
If you need a gem for posgres do:
env ARCHFLAGS="-arch x86_64" gem install pg
Install Instrumentation, in my case (postgres version 9.0.4):
psql -d postgres < /usr/local/Cellar/postgresql/9.0.4/share/postgresql/contrib/adminpack.sql
At this moment, you installed postgress (it’s only a note). Ok, let’s create a new role:
psql -d postgres
With this command, you’ll see all roles created:
postgres-# \du
We create a new user called postgres like this way:
postgres=# CREATE ROLE postgres SUPERUSER CREATEDB CREATEROLE LOGIN;
And that’s all. If you list all users again you’ll see that a new user has been created.