似乎无法在mac上安装mysql

似乎无法在mac上安装mysql,mysql,ruby-on-rails,rubygems,Mysql,Ruby On Rails,Rubygems,在做了下面的建议之后,我仍然得到一个错误 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: r

在做了下面的建议之后,我仍然得到一个错误

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
那应该是

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
不是

(gem名称和构建选项之间有两个连字符,构建选项前面有两个连字符)


您可能还需要设置ARCHFLAGS变量。请参阅。

您需要安装mysql开发库,因为mysql gem包含与它们链接的本机代码。mac上最简单的方法是使用brew——我使用过它,它工作得非常完美,但任何好的mac软件包管理器都可以工作(或者您可以从源代码安装mysql)

Brew安装: 安装后,只需键入:

sudo gem install mysql — –with-mysql-config=/usr/local/mysql/bin/mysql_config

默认情况下,所有brew Recipient都会安装开发库。

brew很棒,但是如果@jgervin还没有使用它,那么仅仅安装mysql就太麻烦了。mysql站点的二进制软件包做得很好。不需要从源代码编译或使用新的包管理系统。是的,我同意,重要的一点是除了普通的libs之外还要安装dev库。优点是brew“免费”完成这项工作。可从mysql下载的安装程序也可以为您完成这一切。它与brew一样易于安装。好吧,如果你还没有安装自制软件,这是一个很棒的建议。它不仅安装dev和headers库,还安装mysql\u config和其他mysql\u*命令。mysql周围的许多Python和Ruby脚本都需要这两种语言。MAMP仅与mysql_*一起提供,未找到标题。我执行了
brew安装mysql',并成功安装了mysql。但是我找不到mysql开发文件
,mysql-devel'提供的文件找不到。如何安装开发文件?顺便说一句,不要在ruby 1.9.x中使用mysql gem,因为它不支持正确的编码。改用mysql2gem。
sudo gem install mysql — –with-mysql-config=/usr/local/mysql/bin/mysql_config
brew install mysql