• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

RubyonRails,“无法启动此程序,因为计算机中丢失LIBMYSQL.dll”问题解决 ...

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

http://blog.csdn.net/abbuggy/article/details/7405192

我的电脑使用Ruby on Rails与MySQL连接时,会提示“无法启动此程序,因为计算机中丢失LIBMYSQL.dll。尝试重新安装程序以解决此问题”(This application has failed to start because LIBMYSQL.DLL was not found.)的错误。

软件版本:

Win7 64位
E:\greensoft\RailsInstaller>mysql -v
Server version: 5.5.17 MySQL Community Server (GPL)

E:\greensoft\RailsInstaller>ruby -v
ruby 1.9.3p125 (2012-02-16) [i386-mingw32]
E:\greensoft\RailsInstaller>rails -v
Rails 3.2.1
E:\greensoft\RailsInstaller>gem list mysql2
mysql2 (0.3.11 x86-mingw32)

尝试过将MySQL\MySQL Server 5.5\lib下的libmysql.dll和libmysql.lib拷贝到Ruby/bin中。报错换成

E:\greensoft\RailsInstaller\Sites\simple_site>rails server
E:/greensoft/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2/mysql2.rb:2:in `require': 193: %1 不是有效的 Win32 应用程序。   - E:/greensoft/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2/1.9/mysql2.so (LoadError)
	from E:/greensoft/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2/mysql2.rb:2:in `<top (required)>'
	from E:/greensoft/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2.rb:9:in `require'
	from E:/greensoft/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2.rb:9:in `<top (required)>'
	from E:/greensoft/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.0.22/lib/bundler/runtime.rb:68:in `require'
	from E:/greensoft/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.0.22/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
	from E:/greensoft/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.0.22/lib/bundler/runtime.rb:66:in `each'
	from E:/greensoft/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.0.22/lib/bundler/runtime.rb:66:in `block in require'
	from E:/greensoft/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.0.22/lib/bundler/runtime.rb:55:in `each'
	from E:/greensoft/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.0.22/lib/bundler/runtime.rb:55:in `require'
	from E:/greensoft/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.0.22/lib/bundler.rb:122:in `require'
	from E:/greensoft/RailsInstaller/Sites/simple_site/config/application.rb:7:in `<top (required)>'
	from E:/greensoft/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1/lib/rails/commands.rb:53:in `require'
	from E:/greensoft/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1/lib/rails/commands.rb:53:in `block in <top (required)>'
	from E:/greensoft/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1/lib/rails/commands.rb:50:in `tap'
	from E:/greensoft/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1/lib/rails/commands.rb:50:in `<top (required)>'
	from script/rails:6:in `require'
	from script/rails:6:in `<main>
后来才知道这是由于32位的Ruby与64位的MySQL的不兼容造成的。

不用重装操作系统,也不用重装MySQL,使用32位的MySQL connector来屏蔽这些问题。下载时请看清32位windows的zip版本。
http://dev.mysql.com/downloads/connector/c/



下载下来解压缩,将lib目录下的libmysql.dll和libmysql.lib拷贝到Ruby/bin目录下。问题解决!

E:\greensoft\RailsInstaller\Sites\simple_site>rails server
=> Booting WEBrick
=> Rails 3.2.1 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2012-03-29 00:33:30] INFO  WEBrick 1.3.1
[2012-03-29 00:33:30] INFO  ruby 1.9.3 (2012-02-16) [i386-mingw32]
[2012-03-29 00:33:30] INFO  WEBrick::HTTPServer#start: pid=4596 port=3000

http://blog.csdn.net/abbuggy/article/details/7405192


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
[译林系列--Ruby]通过IronRuby和C#学习Ruby[2]发布时间:2022-07-14
下一篇:
ruby中的字符串分隔符--split发布时间:2022-07-14
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap