New to rails and web development and after working for 4 weeks on this project I just discovered that sqlite3 doesn't work on heroku. They have a tutorial on their webpage on how to change the database for my rails app from sqlite3 to postgresql.
First I removed the gem 'sqlite3'
and replaced it with gem 'pg'
.
Then I ran bundle install and changed config/database.yml
From
对于rails和web开发的新手以及在这个项目上工作4周之后,我发现sqlite3在heroku上不起作用。他们在他们的网页上有一个关于如何将我的rails应用程序的数据库从sqlite3更改为postgresql的教程。首先,我删除了gem的sqlite3'并将其替换为gem'pg'。然后我运行了bundle install并更改了config / database.yml From
default: &default
adapter: sqlite3
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000
development:
<<: *default
database: db/development.sqlite3
test:
<<: *default
database: db/test.sqlite3
production:
<<: *default
database: db/production.sqlite3
To
至
default: &default
adapter: postgresql
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000
development:
<<: *default
database: my_newapp_development
test:
<<: *default
database: my_newapp_test
production:
<<: *default
database: my_newapp_production
So after this I try running db:create but it says "could not connect to server: Connection refused (0x0000274D/10061) Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? " on line "return PG::Connection.new( *args )". Any help appreciated.
所以在此之后我尝试运行db:create但它说“无法连接到服务器:连接被拒绝(0x0000274D / 10061)服务器是否在主机”localhost“(:: 1)上运行并接受端口5432上的TCP / IP连接? “在线”返回PG :: Connection.new(* args)“。任何帮助赞赏。
1 个解决方案
#1
1
Please check if postgresql is installed on your local machine using terminal.
请检查本地计算机上是否使用终端安装了postgresql。
psql --version
psql --version
If installed, then check if the psql server is running or not.
如果已安装,请检查psql服务器是否正在运行。
ps aux | grep postgresql
ps aux | grep postgresql
To start postgres server, run the following command on terminal
要启动postgres服务器,请在终端上运行以下命令
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
pg_ctl -D / usr / local / var / postgres -l /usr/local/var/postgres/server.log start
#1
1
Please check if postgresql is installed on your local machine using terminal.
请检查本地计算机上是否使用终端安装了postgresql。
psql --version
psql --version
If installed, then check if the psql server is running or not.
如果已安装,请检查psql服务器是否正在运行。
ps aux | grep postgresql
ps aux | grep postgresql
To start postgres server, run the following command on terminal
要启动postgres服务器,请在终端上运行以下命令
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
pg_ctl -D / usr / local / var / postgres -l /usr/local/var/postgres/server.log start