Rails: Rake Db:Create:All (Could Not Connect to Server)

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.

  1. in terminal psql template1
  2. CREATE USER <username from config/database.yml if specified> with password '<password from config/database.yml if specified>';
  3. ALTER USER <username ...> WITH SUPERUSER;
  4. CREATE DATABASE chat_development WITH OWNER = '<username ...>';
  5. 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



Leave a reply



Submit