MAC 和 Postgresql 第二篇

[url=http://hlee.iteye.com/blog/1689304]非常有用的相关资料[/url]

[color=red]UPDATE(05/06/2013):[/color]
still works fine for MAC

modify
/usr/local/var/postgres/postgresql.conf
get localhost works


pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log restart

还是说brew安装,之前之后的事

1. 用brew安装postgresql,很忌讳rvm的gcc,要用xcode的command line

2. brew装完要设置路径,就是local那个不然,就会莫名其妙的错误,总用系统的postgresql


PATH=/usr/local/bin:$PATH:$HOME/.rvm/bin # Add Brew and RVM to PATH for scripting
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # This loads RVM Kens-MacBook-Pro:reptile_nai


重新安装攻略


brew rm postgresql --force

sudo /sbin/SystemStarter stop postgresql-8.4
sudo rm -rf /Applications/PostgreSQL\ 8.4
sudo rm -rf /etc/postgres-reg.ini
sudo rm -rf /Library/StartupItems/postgresql-8.4
sudo rm -rf /Library/PostgreSQL/8.4
sudo dscl . delete /users/postgres

nano /etc/profile

brew update
brew install postgresql

initdb /usr/local/var/postgres
cp /usr/local/Cellar/postgresql/9.1.4/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start

gem install pg




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.



参考:
[url]http://raulbarroso.com/post/8656188824/installing-postgres-with-brew-in-macosx[/url]
[url]http://nextmarvel.net/blog/2011/09/brew-install-postgresql-on-os-x-lion/[/url]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值