[英]“gem install mysql2” on Mac with MAMP 2.2
When trying to run a rails server
in my current directory (which is a new rails project), it says that I need to install the mysql2
gem. 尝试在当前目录(这是一个新的Rails项目)中运行
rails server
时,它说我需要安装mysql2
gem。 At first, I had no idea what this meant... Then, I did some poking around, and finally decided to install the gem. 最初,我不知道这意味着什么...然后,我四处摸索,最后决定安装gem。 However, I am getting this super pesky error (seeing as I just spent 2 hours trying to investigate, and solve another error).
但是,我遇到了这个超级讨厌的错误(看到我刚刚花了2个小时试图调查并解决另一个错误)。 I am on the brink of giving up, but I really want to try rails.
我快要放弃了,但是我真的很想尝试护栏。 Please help!
请帮忙!
Currently, if I run sudo gem install mysql2
, or even as some people told me to do online, gem install mysql -- \\ --with-mysql-config=/Applications/MAMP/Library/bin/mysql_config
(I have MAMP), it gives me the following error: 当前,如果我运行
sudo gem install mysql2
,或者甚至有人说我要在线进行, gem install mysql -- \\ --with-mysql-config=/Applications/MAMP/Library/bin/mysql_config
(我有MAMP) ,它给了我以下错误:
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/Users/vicky/.rvm/rubies/ruby-2.0.0-p247/bin/ruby extconf.rb
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
-----
Using mysql_config at /Applications/MAMP/Library/bin/mysql_config
-----
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
-----
Don't know how to set rpath on your system, if MySQL libraries are not in path mysql2 may not load
-----
-----
Setting libpath to /Applications/MAMP/Library/lib
-----
creating Makefile
make "DESTDIR="
compiling client.c
compiling mysql2_ext.c
compiling result.c
linking shared-object mysql2/mysql2.bundle
ld: warning: directory not found for option '-L/Users/mpapis/.sm/pkg/active/lib'
ld: library not found for -lmysqlclient
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [mysql2.bundle] Error 1
Gem files will remain installed in /Users/username/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/mysql2-0.3.14 for inspection.
Results logged to /Users/username/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/mysql2-0.3.14/ext/mysql2/gem_make.out
Have you considered installing MySQL with homebrew ( http://brew.sh/ )? 您是否考虑过使用自制软件( http://brew.sh/ )安装MySQL? MAMP stands for Mac-Apache-MySQL-PHP (the last part of this being the most important).
MAMP代表Mac-Apache-MySQL-PHP(最后一部分是最重要的)。 I would suggest just installing MySQL directly on your box (homebrew takes care of all the heavy lifting) and afterwards I doubt you'll have any difficulty installing that gem.
我建议直接在您的机器上安装MySQL(自制软件可以解决所有繁重的工作),然后我怀疑您在安装该gem时会遇到任何困难。
To install homebrew -- 要安装自制软件-
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
Run brew doctor
follow any instructions and then afterwards to install MySQL run brew install mysql
and follow any of the instructions it provides for setting up a user, etc... 运行
brew doctor
遵循任何说明,然后安装MySQL,然后运行brew install mysql
并遵循它提供的用于设置用户等的任何说明。
============= UPDATE ============== =============更新=============
SO, what you'll want to do is use brew this way to install MySQL and then install the gem in the normal fashion - sudo gem install mysql2
assuming this works, then you will be able to switch back to the old MySQL install through MAMP via - 所以,您要做的是使用brew方式安装MySQL,然后以正常方式安装gem-
sudo gem install mysql2
假定可行,那么您将可以通过MAMP切换回旧的MySQL安装通过-
sudo nano /etc/paths
then add this line to the top of the document - 然后将此行添加到文档顶部-
/Applications/MAMP/Library/bin
restart your terminal and then run mysql
to double check that you are using the MAMP installation of MySQL, and you'll be good to go. 重新启动您的终端,然后运行
mysql
再次检查您是否正在使用MySQL的MAMP安装,一切都会顺利进行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.