0

I am trying to make a rails 3.1 app using mysql, its my first time using it I am getting an error when I try to rake db:create

The Error

Can't connect to local MySQL server through socket '/tmp/mysql.socket' (2) Couldnt create database for {database.yml info in here} (if you set the charset manually, make sure you have a matching collation)

I was looking at this link http://weblog.rubyonrails.org/2009/8/30/upgrading-to-snow-leopard/ which was posted in this question here rake db:create - collation issues

but I dont think that applies, doesnt mysql get installed when i do install gem mysql 'gem-version'? can someone please help me solve this error? I am also running osx 10.7

Thank you very much in advance!

This is what my gem file looks like

gem 'rails', '3.2.13'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem "mysql2"
gem "activerecord-mysql2-adapter"

gem 'pry'
gem 'pry-debugger'


# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'
  gem 'uglifier', '>= 1.0.3'
end
    group :development, :test do
        gem 'rspec-rails', '~> 2.0'
        gem 'database_cleaner'
        gem 'shoulda-matchers'
    end

    gem 'jquery-rails'

my database.yml

development:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: Training_development
  pool: 5
  username: root
  password:
  host: localhost

# 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
  encoding: utf8
  reconnect: false
  database: Training_test
  pool: 5
  username: root
  password:
  host: localhost

production:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: Training_production
  pool: 5
  username: root
  password:
  host: localhost
Community
  • 1
  • 1
cdm89
  • 165
  • 2
  • 12
  • Your config/database.yml should have : development: adapter: mysql2 encoding: utf8 database: _development pool: 5 username: root password: socket: /tmp/mysql.sock And use mysql2 gem. – Anil Jul 30 '13 at 14:59
  • Hey thank you for your response, I updated the gem file, but the database.yml file doesnt have "socket:" do i just add this under password? – cdm89 Jul 30 '13 at 15:11
  • after adding "socket:" i still get the same error, I appreciate your response thank you very much but can you be a little more specific? – cdm89 Jul 30 '13 at 15:13
  • Try creating the db manually. From terminal: "mysql -uroot" This will take you inside mysql. Then do "create database Training_development;" . I also see host specified, instead of " socket: /tmp/mysql.sock" in your .yml. – Anil Jul 30 '13 at 15:43

0 Answers0