似乎无法在mac上安装mysql

jdo*_*dog 0 mysql rubygems ruby-on-rails

sudo gem install mysql — –with-mysql-config=/usr/local/mysql/bin/mysql_config
/usr/local/lib/ruby/1.9.1/optparse.rb:1262: warning: regexp match /.../n against to UTF-8 string
/usr/local/lib/ruby/1.9.1/optparse.rb:1278: warning: regexp match /.../n against to UTF-8 string
/usr/local/lib/ruby/1.9.1/optparse.rb:1262: warning: regexp match /.../n against to UTF-8 string
/usr/local/lib/ruby/1.9.1/optparse.rb:1278: warning: regexp match /.../n against to UTF-8 string
Building native extensions.  This could take a while...
ERROR:  Error installing mysql:
    ERROR: Failed to build gem native extension.

/usr/local/bin/ruby extconf.rb
checking for mysql_ssl_set()... no
checking for rb_str_set_len()... no
checking for rb_thread_start_timer()... no
checking for mysql.h... yes
creating Makefile

make
gcc -I. -I/usr/local/include/ruby-1.9.1/i386-darwin9.8.0 -I/usr/local/include/ruby-1.9.1/ruby/backward -I/usr/local/include/ruby-1.9.1 -I. -DHAVE_MYSQL_H  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -I/usr/local/mysql/include/mysql -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT  -DDONT_DECLARE_CXA_PURE_VIRTUAL -fno-common  -O2 -g -Wall -Wno-parentheses -pipe -fno-common  -o mysql.o -c mysql.c
In file included from /usr/local/include/ruby-1.9.1/ruby.h:32,
                 from mysql.c:5:
/usr/local/include/ruby-1.9.1/ruby/ruby.h: In function ‘INT2NUM’:
/usr/local/include/ruby-1.9.1/ruby/ruby.h:464: warning: comparison is always true due to limited range of data type
/usr/local/include/ruby-1.9.1/ruby/ruby.h:464: warning: comparison is always true due to limited range of data type
/usr/local/include/ruby-1.9.1/ruby/ruby.h: In function ‘UINT2NUM’:
/usr/local/include/ruby-1.9.1/ruby/ruby.h:472: warning: comparison is always true due to limited range of data type
mysql.c: In function ‘escape_string’:
mysql.c:290: error: lvalue required as left operand of assignment
mysql.c:290: error: lvalue required as left operand of assignment
mysql.c: In function ‘real_escape_string’:
mysql.c:434: error: lvalue required as left operand of assignment
mysql.c:434: error: lvalue required as left operand of assignment
make: *** [mysql.o] Error 1


Gem files will remain installed in /usr/local/lib/ruby/gems/1.9.1/gems/mysql-2.8.1 for inspection.
Results logged to /usr/local/lib/ruby/gems/1.9.1/gems/mysql-2.8.1/ext/mysql_api/gem_make.out
ERROR:  Could not find a valid gem '—' (>= 0) in any repository
ERROR:  Could not find a valid gem '–with-mysql-config=/usr/local/mysql/bin/mysql_config' (>= 0) in any repository
Run Code Online (Sandbox Code Playgroud)

在做了下面的建议后,我仍然收到错误.

sudo gem install mysql - --with-mysql-config =/usr/local/mysql/bin/mysql_config /usr/local/lib/ruby/1.9.1/optparse.rb:1262:warning:regexp match/.. ./n反对UTF-8字符串/usr/local/lib/ruby/1.9.1/optparse.rb:1278:警告:regexp匹配/.../n反对UTF-8字符串/ usr/local/lib /ruby/1.9.1/optparse.rb:1262:警告:正则表达式匹配/.../n反对UTF-8字符串/usr/local/lib/ruby/1.9.1/optparse.rb:1278:警告: regexp匹配/.../n反对UTF-8字符串构建本机扩展.这可能需要一段时间...错误:安装mysql时出错:错误:无法构建gem原生扩展.

sudo gem install mysql —- –-with-mysql-config=/usr/local/mysql/bin/mysql_config
/usr/local/lib/ruby/1.9.1/optparse.rb:1262: warning: regexp match /.../n against to UTF-8 string
/usr/local/lib/ruby/1.9.1/optparse.rb:1278: warning: regexp match /.../n against to UTF-8 string
/usr/local/lib/ruby/1.9.1/optparse.rb:1262: warning: regexp match /.../n against to UTF-8 string
/usr/local/lib/ruby/1.9.1/optparse.rb:1278: warning: regexp match /.../n against to UTF-8 string
Building native extensions.  This could take a while...
ERROR:  Error installing mysql:
    ERROR: Failed to build gem native extension.

        /usr/local/bin/ruby extconf.rb
checking for mysql_ssl_set()... yes
checking for rb_str_set_len()... no
checking for rb_thread_start_timer()... no
checking for mysql.h... yes
creating Makefile

make
gcc -I. -I/usr/local/include/ruby-1.9.1/i386-darwin9.8.0 -I/usr/local/include/ruby-1.9.1/ruby/backward -I/usr/local/include/ruby-1.9.1 -I. -DHAVE_MYSQL_SSL_SET -DHAVE_MYSQL_H  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -I/usr/local/mysql/include  -g -Os -arch x86_64 -fno-common   -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT  -DDONT_DECLARE_CXA_PURE_VIRTUAL -fno-common  -O2 -g -Wall -Wno-parentheses -pipe -fno-common  -o mysql.o -c mysql.c
In file included from /usr/local/include/ruby-1.9.1/ruby.h:32,
                 from mysql.c:5:
/usr/local/include/ruby-1.9.1/ruby/ruby.h: In function ‘INT2NUM’:
/usr/local/include/ruby-1.9.1/ruby/ruby.h:464: warning: comparison is always true due to limited range of data type
/usr/local/include/ruby-1.9.1/ruby/ruby.h:464: warning: comparison is always true due to limited range of data type
/usr/local/include/ruby-1.9.1/ruby/ruby.h: In function ‘UINT2NUM’:
/usr/local/include/ruby-1.9.1/ruby/ruby.h:472: warning: comparison is always true due to limited range of data type
mysql.c: In function ‘escape_string’:
mysql.c:290: error: lvalue required as left operand of assignment
mysql.c:290: error: lvalue required as left operand of assignment
mysql.c: In function ‘real_escape_string’:
mysql.c:434: error: lvalue required as left operand of assignment
mysql.c:434: error: lvalue required as left operand of assignment
make: *** [mysql.o] Error 1


Gem files will remain installed in /usr/local/lib/ruby/gems/1.9.1/gems/mysql-2.8.1 for inspection.
Results logged to /usr/local/lib/ruby/gems/1.9.1/gems/mysql-2.8.1/ext/mysql_api/gem_make.out
ERROR:  Could not find a valid gem '—-' (>= 0) in any repository
ERROR:  Could not find a valid gem '–-with-mysql-config=/usr/local/mysql/bin/mysql_config' (>= 0) in any repository
Run Code Online (Sandbox Code Playgroud)

检查mysql_ssl_set()...是检查rb_str_set_len()...没有检查rb_thread_start_timer()...没有检查mysql.h ...是创建Makefile

制作gcc -I.-I/usr/local/include/ruby​​-1.9.1/i386-darwin9.8.0 -I/usr/local/include/ruby​​-1.9.1/ruby​​/backward -I/usr/local/include/ruby​​-1.9 .1 -I.-DHAVE_MYSQL_SSL_SET -DHAVE_MYSQL_H -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I在/ usr /本地/ mysql /下包括-g -Os -arch x86_64的-fno-共同-D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT -DDONT_DECLARE_CXA_PURE_VIRTUAL -fno常见-02 -g -Wall - Wno-parentheses -pipe -fno-common -o mysql.o -c mysql.c在/usr/local/include/ruby-1.9.1/ruby.h:32中包含的文件中,来自mysql.c:5:/ usr/local/include/ruby​​-1.9.1/ruby​​/ruby​​.h:在函数'INT2NUM'中:/usr/local/include/ruby-1.9.1/ruby/ruby.h:464:警告:比较总是由于数据类型的范围有限,因此为真/usr/local/include/ruby-1.9.1/ruby/ruby.h:464:警告:由于数据类型的范围有限,比较始终为真/ usr/local/include/ruby -1.9.1/ruby​​/ruby​​.h:在函数'UINT2NUM'中:/usr/local/include/ruby-1.9.1/ruby/ruby.h:472:警告:由于数据范围有限,比较始终为真type mysql.c:在函数'escape_string'中:mysql.c:290:错误:左值作为赋值的左操作数需要左值 t mysql.c:290:错误:作为赋值mysql.c的左操作数需要左值:在函数'real_escape_string'中:mysql.c:434:错误:需要左值作为赋值mysql.c的左操作数:434:错误:左值作为赋值的左操作数需要make:* [mysql.o]错误1

Gem文件将保留在/usr/local/lib/ruby/gems/1.9.1/gems/mysql-2.8.1中以供检查.结果记录到/usr/local/lib/ruby/gems/1.9.1/gems/mysql-2.8.1/ext/mysql_api/gem_make.out错误:找不到有效的宝石' - '(> = 0)在任何存储库中错误:在任何存储库中找不到有效的gem'--with-mysql-config =/usr/local/mysql/bin/mysql_config'(> = 0)

Gre*_*zky 6

您需要安装mysql dev库,因为mysql gem包含与它们链接的本机代码.在mac上最简单的方法是使用brew - 我已经使用过它并且它完美无缺,但是任何好的mac包管理器都可以工作(或者你可以从源代码安装mysql).

Brew安装:http://mxcl.github.com/homebrew/安装 完成后输入:

brew install mysql
Run Code Online (Sandbox Code Playgroud)

默认情况下,所有brew收件人都安装dev库.