5 ruby postgresql ruby-on-rails-3 ruby-on-rails-3.1
我正在使用PostgreSQL 9.1.3(在x86_64-pc-linux-gnu上的PostgreSQL 9.1.3,由gcc-4.6.real(Ubuntu/Linaro 4.6.1-9ubuntu3)4.6.1,64位编译)和rails 3.2 ubuntu 11.10上的.2或3.2.1.
现在,我可以使用PostgreSQL连接下面的命令
su postgres
输入密码,我可以看到postgres =#
我将以下详细信息放在我的config/database.yml中并执行" rails db "它工作正常.
development:
adapter: postgresql
encoding: utf8
reconnect: false
database: sample_app_db
pool: 5
username: postgres
password: passwordhere
host: localhost
Run Code Online (Sandbox Code Playgroud)我正在使用rvm来访问我的rails环境.但是当我使用"rails s"命令启动服务器并使用"http:// localhost:3000"命中url时,请说 - connection not established.
AMI*_*ING 13
试试这种方式,
sudo -u postgres createuser -D -P your-current-ubuntu-username
Run Code Online (Sandbox Code Playgroud)
和
sudo -u postgres createdb -O your-current-ubuntu-username your-database
Run Code Online (Sandbox Code Playgroud)
打开这个文件 /etc/postgresql/9.1/main/pg_hba.conf
仅更改此行:
local all all peer
Run Code Online (Sandbox Code Playgroud)
对此:
local all all md5
Run Code Online (Sandbox Code Playgroud)
别忘了重新启动postgres服务器:
sudo service postgresql restart
Run Code Online (Sandbox Code Playgroud)
现在使用此命令检查
psql -d your-database -U your-current-ubuntu-username -W
Run Code Online (Sandbox Code Playgroud)
它应该工作
这个解决方案适用于postgresql-9.1,这是安装方式
sudo apt-get install postgresql-9.1
Run Code Online (Sandbox Code Playgroud)