0

当我尝试使用 rake 命令创建数据库时出现此错误。

这是我的 database.yml 文件

   # 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

现在我不确定为什么会收到此错误。

4

3 回答 3

1

我想你有旧的 mysql 服务器。因此,如果您有旧版本,请安装新的。

于 2012-04-23T13:24:43.870 回答
1

替换host: localhosthost: 127.0.0.1

于 2013-02-20T17:35:19.403 回答
1

您可以使用套接字连接而不是端口进行连接,您可以使用这种形式,这很容易

对于 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

用于 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

我希望这种方法能奏效

于 2013-02-20T18:11:03.687 回答