Rails: rake db:create:all (could not connect to server) psql works fine
Incorrect config, this was fixed by including the hostname with the configuration (see below), one interesting note is that this is only necessary for the macbook pro that I'm running on and does not occur on the Linux box I use.
development:
adapter: postgresql
encoding: unicode
database: blog_development
pool: 5
username: myusername
password:
host: localhost
port: 5432
test:
adapter: postgresql
encoding: unicode
database: blog_test
pool: 5
username: myusername
password:
host: localhost
port: 5432
production:
adapter: postgresql
encoding: unicode
database: blog_production
pool: 5
username: myusername
password:
host: localhost
port: 5432
Unable to create database with rake db:create command
Had this issue and never quite figured out why rails was doing this, but below should fix it.
- in terminal
psql template1
CREATE USER <username from config/database.yml if specified> with password '<password from config/database.yml if specified>';
ALTER USER <username ...> WITH SUPERUSER;
CREATE DATABASE chat_development WITH OWNER = '<username ...>';
CREATE DATABASE chat_test WITH OWNER = '<username ...>';
you don't need step 2/3, or the WITH OWNER = '<username>';
unless you specify a user/password in config/database.yml
.
Some common mistakes, pay close attention to where I have put single quotes, and don't forget the semi-colons!
Rails: rake db:create:all fails to connect to PostgreSQL database
@Riateche: Finally, I saw that the database configuration for test environment misses the explicit settings for host and port. After I added the settings to the test environment, I was able to run the command bundle exec rake db:create:all
successfully.
I must say, I do not like that they suggest those settings for the development enviroment, but did not add them for the other environments. That makes it very likely to miss them, as I proofed.
test:
adapter: postgresql
encoding: unicode
database: my_test_app_test
pool: 5
username: johndoe
password: password
host: localhost
port: 5433
Cannot rake db:create:all -- Couldn't create database for {encoding=utf8, username=root, adapter=mysql
So, after about 3 or 4 days of googling and trying so many different things, I stumbled on this somehow:
http://geryit.com/blog/2011/01/installing-mysql-with-rails-on-mac-os-x-snow-leopard/
And guess what? IT WORKS! PERFECTLY. Which leads me to believe that the problem lies within MySQL 5.5.10. Something about it will not just play nice with my ruby/rails environment. However, once I followed the instructions on the link above (which include uninstalling mysql and re-installing 5.1), my app now runs perfectly on my local machine.
Hope this helps someone!
Postgres - could not connect to server after trying rake db:create:all
http://postgresapp.com defines itself as "The easiest way to get started with PostgreSQL on the Mac. Just download, drag to the applications folder, and double-click". It worked perfectly for me.
rake db:migrate Could not connect to server error
To install postgres you may use these commands:
sudo apt-get install postgresql-9.1 postgresql-server-dev-9.1
Then you should set password to newly user
sudo passwd postgres
You have to ensure that database configuration parameters(like username, password etc) in config/database.yml are correct.
And then:
rake db:setup
will create databases and restore schemas if any.
Related Topics
How to Add Conditional Rubygem Requirements to a Gem Specification
How to Get Gmail Oauth or Xauth Tokens with Omniauth
Rotating Letters in a String So That Each Letter Is Shifted to Another Letter by N Places
How to Search for Useful Ruby Gems
Ruby on Rails - Activerecord::Relation Count Method Is Wrong
Rails 5 - Using Polymorphic Associations - Rendering the Views
Why Can't I Create an Array as a Column in a Table in Rails
Test (With Rspec) a Controller Outside of a Rails Environment
Error Building Ruby in Sublime Text Editor
How to Change Ruby to Version 1.9.3 (Again) with Rvm
Rails Error Message Displays Key and I Only Want Value
Ruby: Cannot Install Watir Gem on Windows
Dynamically Create a Class Inherited from Activerecord
Rails: Parameterfilter::Compiled_Filter Tries to Dup Symbol
Can't All or Most Cases of 'Each' Be Replaced with 'Map'
Using Watir to Check for Bad Links