我需要将我的应用程序从 sqlite 移动到 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
时,出现此错误
Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
Couldn't create database for {"adapter"=>"mysql2", "encoding"=>"utf8", "database"=>"test-db", "pool"=>5, "timeout"=>5000}, charset: utf8, collation: utf8_unicode_ci
(if you set the charset manually, make sure you have a matching collation)
我需要做什么?
最佳答案
您需要将套接字添加到database.yml
获取套接字:
mysqladmin variables | grep socket
这给了我在我的系统(OSX)上的信息:
socket: /tmp/mysql.sock
在 Linux 上:
socket: /var/run/mysqld/mysqld.sock
关于mysql - Nitrous.io :moving rails app to mysql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19861542/