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
在執行下面的建議後,我仍然收到錯誤消息。似乎無法在mac上安裝mysql
sudo gem install mysql - --with-mysql-config =/usr/local/mysql/bin/mysql_config /usr/local/lib/ruby/1.9.1/optparse.rb:1262:warning:正則表達式匹配/.../n針對UTF-8字符串 /usr/local/lib/ruby/1.9.1/optparse.rb:1278:警告:正則表達式匹配/.../n針對UTF-8字符串 /usr/local/lib/ruby/1.9.1/optparse.rb:1262:警告:regexp匹配UTF-8字符串/.../n字符串 /usr/local/lib/ruby/1.9.1/ optparse.rb:1278:警告:正則表達式匹配/.../n針對UTF-8字符串 構建原生擴展。這可能需要一段時間... 錯誤:安裝mysql時出錯: 錯誤:無法構建gem本機擴展。
/usr/local/bin/ruby extconf.rb
檢查mysql_ssl_set()...是 檢查rb_str_set_len()...沒有 檢查rb_thread_start_timer()...沒有 檢查mysql.h中...是 創建的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 /本地/ 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-括號-pipe -fno-common -o mysql.o -c mysql.c 從mysql.c中包含/usr/local/include/ruby-1.9.1/ruby.h:32, 的文件:5 : /usr/local/include/ruby-1.9.1/ruby/ruby.h:在函數'INT2NUM'中: /usr/local/include/ruby-1.9.1/ruby/ruby.h:464:warning :由於數據類型範圍有限,比較始終爲真 /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:警告:由於數據類型範圍有限,比較始終爲真 mysql.c:在函數'escape_string'中: mysql.c :290:error:作爲賦值左操作數所需的左值 mysql.c:290:錯誤:作爲賦值左操作數需要左值 mysql.c:函數'real_escape_string': mysql.c:434:error:需要左值作爲分配 mysql.c的左操作數:434:錯誤:要求作爲分配的左操作數左值 化妝:* [mysql.o]錯誤1
寶石文件仍將安裝在/ 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 錯誤:無法在任何存儲庫中找到有效的gem' - '(> = 0) 錯誤:找不到有效的gem'--with-mysql-config =/usr/local/mysql/bin/mysql_config '(> = 0)中的任何存儲庫
順便說一句,不要使用MySQL的寶石紅寶石1.9.x,因爲它不支持正確的編碼。改用mysql2 gem。 – 2011-03-13 16:19:59