windows安装rails3.1.1 ruby1.9.2 mysql5.5.8
windows下使用RailsInstaller整合开发环境包,原装rails版本为3.1.1,ruby版本为1.9.2,mysql2适配器的版本为mysql2-0.3.11,mysql适配器版本需与rails版本相对应,可以通过以下命令进行mysql适配器的安装
gem install mysql2 -v 0.3.11 --platform x86-mingw3
接着将mysql安装的bin目录下得libmysql.dll文件copy至ruby的安装bin目录即可。
此时已经完成了大部分配置操作,现在通过以下命令
rails new myapp -d=mysql
生成项目,使用rails s启动服务器,此时会爆出类似这样的错误
`require': Incorrect MySQL client library version! This gem was compiled for 6.0.0 but the client library is 5.0.27.
版本不对?baidu,google找到解决办法到以下链接下载该文件http://dev.mysql.com/downloads/mirror.php?id=377978
将其中的libmysql.dll覆盖ruby的安装bin目录的libmysql.dll文件。
重新启动,一切OK。
使用命令
rake db:create创建数据库,当然需要在database.yml
development: adapter: mysql2 encoding: utf8 reconnect: false database: depots_development pool: 5 username: root password: password host: localhost
除数据库外,还需要将整个项目文件设置为utf-8编码,在再所有.rb后缀的脚本上加入
#encoding: utf-8即可。经过本人测试,通过以上操作,rails在windows下环境算是搭建好了。