noobie-php
noobie-php

Reputation: 7233

Can't connect to MySQL server on 'localhost' (10061) while creating DB using rake command

i get this error when i try to create a database using rake command.

this is my database.yml file

   # MySQL.  Versions 4.1 and 5.0 are recommended.
   # 
   # Install the MYSQL driver
   #   gem install mysql2
   # Ensure the MySQL gem is defined in your Gemfile
   #   gem 'mysql2'
   #
   # And be sure to use new-style password hashing:
   #   http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: SIMS_development
pool: 5
username: root
password:
host: localhost
port: 3306


# Do not set this db to the same as development or production.
test:
 adapter: mysql2
 encoding: utf8
 reconnect: false
 database: SIMS_test
 pool: 5
 username: root
 password:
 host: localhost
 port: 3306

now i am not sure why i am getting this error.

Upvotes: 0

Views: 3888

Answers (3)

trejo08
trejo08

Reputation: 2528

you can use socket connection instead of a port for your connection, you can use of this form, it's very easy

for Linux:

development:
adapter: mysql2
encoding: utf8
reconnect: false
database: your_database_name
pool: 5
username: your_username_db
password: your_password_db
socket: /var/run/mysqld/mysqld.sock

for MAC

development:
adapter: mysql2
encoding: utf8
reconnect: false
database: your_database_name
pool: 5
username: your_username_db
password: your_password_db
socket: /tmp/mysql.sock

I hope this method will serve

Upvotes: 1

Maicon Keller
Maicon Keller

Reputation: 11

Substitute host: localhost with host: 127.0.0.1

Upvotes: 1

StormMan
StormMan

Reputation: 193

I think you have old mysql server. So please install new one if you have old version.

Upvotes: 1

Related Questions