0

I am running Ubuntu 10.04, Rails 3.0.7, Ruby 1.9.2

I started with this link: Convert a Ruby on Rails app from sqlite to MySQL?

I successfully installed 'mysql2'

database.yml :

# SQLite version 3.x
#   gem install sqlite3
development:
  adapter: mysql2
  database: db/development.mysql2
  pool: 5
  timeout: 5000 
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  adapter: mysql2
  database: db/test.mysql2
  pool: 5
  timeout: 5000

production:
  adapter: mysql2
  database: db/production.mysql2
  pool: 5
  timeout: 5000

When i get to step 5 :

rake db:create

I get this error (with trace):

** Invoke db:create (first_time)

** Invoke db:load_config (first_time)

** Invoke rails_env (first_time)

** Execute rails_env

** Execute db:load_config

** Execute db:create

Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

Couldn't create database for {"adapter"=>"mysql2", "database"=>"db/test.mysql2", 
"pool"=>5, "timeout"=>5000}, charset: utf8, collation: utf8_unicode_ci

Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

Couldn't create database for {"adapter"=>"mysql2", "database"=>"db/development.mysql2", 
"pool"=>5, "timeout"=>5000}, charset: utf8, collation: utf8_unicode_ci

Any suggestions?

Community
  • 1
  • 1
Wasi
  • 1,258
  • 4
  • 14
  • 33

1 Answers1

0

The problem is that you haven't started your MySQL server yet, so it's failing to create the database because the server is having the common mysqld.sock error.

Here's a fantastic resource for this: http://matthom.com/archive/2009/06/14/installing-mysql-mac-os-x

On my machine, it works when I start at 'Connecting to MySQL', but there are a couple of other sections explaining alternative resolutions to the socket error.

sscirrus
  • 55,407
  • 41
  • 135
  • 228