【问题标题】:Cannot seem to install mysql on mac似乎无法在 mac 上安装 mysql
【发布时间】:2011-03-13 12:47:16
【问题描述】:
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

【问题讨论】:

  • 顺便说一句,不要将 mysql gem 与 ruby​​ 1.9.x 一起使用,因为它不支持正确的编码。请改用 mysql2 gem。

标签: mysql ruby-on-rails rubygems


【解决方案1】:

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

Brew 安装:Link 安装完成后输入:

brew install mysql

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

【讨论】:

  • Brew 很棒,但是如果@jgervin 还没有使用它,那么仅仅安装 mysql 就会很麻烦。来自 mysql 站点的二进制包就可以了。无需从源代码编译或使用新的包管理系统。
  • 是的,我同意,重要的一点是除了普通库之外还要安装开发库。优点是 brew 这样做是“免费的”。
  • 可从 mysql 下载的安装程序也可以为您完成所有工作。它就像在 brew 中一样易于安装。好吧,如果你还没有安装自制软件,那就是。
  • 很棒的建议。它不仅安装 dev 和 headers 库,还安装 mysql_config 和其他 mysql_* 命令。 mysql 周围的许多 Python 和 Ruby 脚本都需要这两者。 MAMP 仅附带 mysql_*,没有找到标头。
  • 我做了一个brew install mysql' and I was successful in installing the mysql . But I'm not able to find mysql development files which mysql-devel` 没有找到。如何安装开发文件?
【解决方案2】:

应该是这样的

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

不是

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

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

您可能还需要设置 ARCHFLAGS 变量。见here

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-01-02
    • 2021-05-11
    • 1970-01-01
    • 1970-01-01
    • 2014-04-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多