在mac上安装带有rails3的mysql2 gem时出现了非常奇怪的错误

在mac上安装带有rails3的mysql2 gem时出现了非常奇怪的错误,mysql,ruby-on-rails,ruby,database,installation,Mysql,Ruby On Rails,Ruby,Database,Installation,我得到这个错误: 构建本机扩展。这可能需要一段时间 ERROR: Error installing mysql: ERROR: Failed to build gem native extension. /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb --with-mysql-config=/Applications/MAMP/Library/bin/mysql_config

我得到这个错误:

构建本机扩展。这可能需要一段时间

ERROR:  Error installing mysql:
    ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb --with-mysql-config=/Applications/MAMP/Library/bin/mysql_config
checking for mysql_ssl_set()... no
checking for rb_str_set_len()... no
checking for rb_thread_start_timer()... no
checking for mysql.h... no
checking for mysql/mysql.h... 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.
我什么都试过了,但还是出错了。出于某种原因,当我运行
locate mysql\u config
时,我得到的结果是:

/Applications/MAMP/Library/bin/mysql\u config
/Applications/MAMP/Library/share/man/man1/mysql\u config.1


我试着用mysql config=/path/you/identified/over/mysql\u config运行了两次
sudo gem install mysql2--–但是我仍然从上面得到了错误。我下载了一个新版本的MySql,我有Xcode,但我仍然收到这些错误。我做错了什么?

MAMP安装是您唯一安装的mysql吗?如果您是从mysql包安装的,那么我认为mysql\u config将安装在/usr/local/bin/mysql\u config中,因此您可能希望尝试:

SudoGem安装mysql2---使用mysql配置==/usr/local/bin/mysql\u config

仅供参考,/Applications/MAMP/Library/share/man/man1/mysql_config.1路径显然是错误的。这是指向mysql_config的man文件,而不是实际的可执行文件

只是想确定一下,你是不是试过这个?(一如所写)

sudogem安装mysql2---使用mysql配置=/Applications/MAMP/Library/bin/mysql\u config


另外,我不确定用MAMP打包的mysql是否有您需要的头文件。您最好从安装mysql,然后尝试安装您的gem。在这种情况下,我认为它会起作用

有时,安装mysql2的旧版本可以正常工作。