为什么数据库配置不起作用?

时间:2015-03-03 11:51:39

标签: mysql ruby-on-rails

我从github克隆了一个repo,当我尝试运行rake db:create时,shell向我显示错误

ruby-2.2.0 ~/ymh (milestone3*) [02:47:02]
weare138$ rake db:create
Couldn't create database for {"adapter"=>"mysql2", "database"=>"development", "username"=>"root", "host"=>"127.0.0.1", "pool"=>5, "port"=>3306, "password"=>"password", "socket"=>"/tmp/mysql.sock"}, {:charset=>"utf8", :collation=>"utf8_unicode_ci"}

有database.yml

development:
  adapter: mysql2
  database: development
  username: root
  host: 127.0.0.1
  pool: 5
  port: 3306
  password: password
  socket: /tmp/mysql.sock

我错了?如何解决?

更新

ruby-2.2.0 ~/ymh (milestone3*) [02:47:38]
weare138$ rake --trace db:create
** Invoke db:create (first_time)
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:create
Couldn't create database for {"adapter"=>"mysql2", "database"=>"development", "username"=>"root", "host"=>"127.0.0.1", "pool"=>5, "port"=>3306, "password"=>"password", "socket"=>"/tmp/mysql.sock"}, {:charset=>"utf8", :collation=>"utf8_unicode_ci"}

2 个答案:

答案 0 :(得分:0)

请你确定你的mysql.sock是正确的。 在ubuntu 14.04中,它位于/var/run/mysqld/mysqld.sock

所以修改后的database.yml文件看起来像

development:
  adapter: mysql2
  database: development
  username: root
  host: 127.0.0.1
  pool: 5
  port: 3306
  password: password
  socket: /var/run/mysqld/mysqld.sock

答案 1 :(得分:0)

如果您的系统中安装了常规pool软件包(我的意思是socket),我认为您无需指定mysqlapt-get install

试着摆脱那些。