Rails安装mysql错误
嗨,我想安装mysql2 gem,但一直失败Rails安装mysql错误,mysql,ruby-on-rails,ruby,Mysql,Ruby On Rails,Ruby,嗨,我想安装mysql2 gem,但一直失败 C:\Users\HuiHui\Documents\ruby 2.0.0>gem install mysql2 -v '0.3.11' Fetching: mysql2-0.3.11.gem (100%) Temporarily enhancing PATH to include DevKit... Building native extensions. This could take a while... ERROR: Error ins
C:\Users\HuiHui\Documents\ruby 2.0.0>gem install mysql2 -v '0.3.11'
Fetching: mysql2-0.3.11.gem (100%)
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
C:/RailsInstaller/Ruby200-x64/bin/ruby.exe extconf.rb
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for main() in -llibmysql... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=C:/RailsInstaller/Ruby200-x64/bin/ruby
--with-mysql-dir
--without-mysql-dir
--with-mysql-include
--without-mysql-include=${mysql-dir}/include
--with-mysql-lib
--without-mysql-lib=${mysql-dir}/
--with-libmysqllib
--without-libmysqllib
Gem files will remain installed in C:/RailsInstaller/Ruby200-x64/lib/ruby/gems/2
.0.0/gems/mysql2-0.3.11 for inspection.
Results logged to C:/RailsInstaller/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-
0.3.11/ext/mysql2/gem_make.out
尽管更改了版本、卸载和安装时没有任何版本,但它仍然存在相同的问题。有人能解释一下吗?我在窗户上做事
附件是日志文件:
编辑
在尝试了中级教程之后,我遇到了这个错误
C:\Users\HuiHui\sutdweb>gem install mysql2 -- --with-mysql-dir=c:\mysql-connecto
r-c-6.1.5-win32
Temporarily enhancing PATH to include DevKit...
Building native extensions with: '--with-mysql-dir=c:\mysql-connector-c-6.1.5-wi
n32'
This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
C:/RailsInstaller/Ruby200-x64/bin/ruby.exe extconf.rb --with-mysql-dir=c:\my
sql-connector-c-6.1.5-win32
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
-----
Using --with-mysql-dir=c:\mysql-connector-c-6.1.5-win32
-----
checking for main() in -llibmysql... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=C:/RailsInstaller/Ruby200-x64/bin/ruby
--with-mysql-dir
--with-mysql-include
--without-mysql-include=${mysql-dir}/include
--with-mysql-lib
--without-mysql-lib=${mysql-dir}/
--with-mysql-dir
--with-mysql-include
--without-mysql-include=${mysql-dir}/include
--with-mysql-lib
--without-mysql-lib=${mysql-dir}/lib
--with-libmysqllib
--without-libmysqllib
Gem files will remain installed in C:/RailsInstaller/Ruby200-x64/lib/ruby/gems/2
.0.0/gems/mysql2-0.3.16 for inspection.
Results logged to C:/RailsInstaller/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-
0.3.16/ext/mysql2/gem_make.out
在您对如何使用gem和mysql2指定配置选项的回答中,是这样的:
gem install mysql2 -- --with-mysql-dir=c:\mysql-connector-c-6.1.1-win32
详情如下:
有人能解释一下吗
当然-问题在于Windows与MYSQL2
gem的兼容性-默认情况下,Windows不附带允许gem与MYSQL连接所需的MYSQL头文件
<>为了安装它,你需要安装MySQL C连接器包,并使用它给你的GEM提供它需要运行的C++头文件:
--
我们已经为此编写了一个教程
如果您执行以下操作,安装mysql2
gem实际上相对简单:
libmysql.dll
复制到Ruby安装中gem install mysql2 --platform=ruby -- ‘--with-mysql-dir=”C:\mysql-connector-path”’
最后,您应该将libmysql.dll
文件从C-Connector
文件的/bin
文件夹复制到Ruby
的/bin
目录中
这应该安装gem你有没有像上面说的那样查看日志以了解更多详细信息?愚蠢的问题是:你正在安装mysql gem(它与真正的mysql库对话)。你真的安装了mysql吗?@sevensacat是的,我检查过了,但我不明白日志中有什么…@TarynEast是的!我有一个mysql工作台,具体取决于你的操作系统——我猜这里是windows(我只能在ubuntu上帮你)。我想在谷歌上搜索“在windows上安装mysql开发头”之类的东西。嗨@Rich Peck,我试过了,他们给了我这个错误。。。C:\Users\HuiHui\sutdweb>gem安装mysql2--platform=ruby----with mysql dir=“C:\Program Files\mysql\mysql-5.5.38-win32”错误:执行gem时。。。(OptionParser::InvalidOption)无效选项:-ùplatform=ruby----with mysql dir=“C:\Program Files\mysql\mysql-5.5.38-win32ö198抱歉,这是命令的格式问题-让我来为您修复现在应该没问题了(如果您从这里复制命令,而不是从中复制命令)gem安装mysql2--platform=ruby--with mysql dir=”C:\Program Files\MySQL\MySQL-5.5.38-win32“'在这里!谢谢!我在尝试了这些步骤后添加了错误消息…请看一下