首页 文章

Nitrous.io:moving rails app到mysql

提问于
浏览
2

我需要将我的应用程序从sqlite移动到mysql . 我按照那个指南

http://help.nitrous.io/mysql/

安装mysql,这是我的yaml文件

developement:
  adapter: mysql2
  encoding: utf8
  database: dev-db
  pool: 5
  timeout: 5000

test:
  adapter: mysql2
  encoding: utf8
  database: test-db
  pool: 5
  timeout: 5000

production:
  adapter: mysql2
  encoding: utf8
  database: prod-db
  pool: 5
  timeout: 5000

当我尝试做 rake db:create 时,我收到此错误

无法通过套接字'/var/run/mysqld/mysqld.sock'连接到本地MySQL服务器(2)无法为{“adapter”=>“mysql2”,“encoding”=>“utf8”创建数据库,“database”=>“test-db”,“pool”=> 5,“timeout”=> 5000},charset:utf8,collation:utf8_unicode_ci(如果你手动设置字符集,请确保你有匹配的排序规则)

我需要做什么?

2 回答

  • 2

    您需要向database.yml添加套接字

    获取套接字:

    mysqladmin variables | grep socket
    

    这给了我我的系统(OSX):

    socket: /tmp/mysql.sock
    

    在Linux上:

    socket: /var/run/mysqld/mysqld.sock
    
  • 0

    类似的事情发生在我身上,我只是更改了默认密码

    mysqladmin -u root password newpassword
    

相关问题