使用MAMP 2.2在Mac上"gem install mysql2"

 小辉0110_737 发布于 2023-02-06 13:56

rails server我尝试在我当前的目录(这是一个新的rails项目)中运行时,它说我需要安装mysql2gem.起初,我不知道这意味着什么......然后,我做了一些戳,最后决定安装宝石.但是,我得到了这个超级麻烦的错误(因为我只花了2个小时试图调查,并解决了另一个错误).我处于放弃的边缘,但我真的想试试铁轨.请帮忙!

目前,如果我跑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

Noah Davis.. 6

您是否考虑过使用自制软件安装MySQL(http://brew.sh/)?MAMP代表Mac-Apache-MySQL-PHP(其中最重要的部分是最重要的).我建议只在你的盒子上直接安装MySQL(自制软件负责所有繁重的工作),然后我怀疑你在安装这个宝石时遇到任何困难.

安装自制软件 -

ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

brew doctor按照任何说明运行,然后安装MySQL运行brew install mysql并按照它为设置用户提供的任何说明等...

=============更新==============

那么,你想要做的就是使用brew这种方式来安装MySQL,然后以正常的方式安装gem - sudo gem install mysql2假设这有效,那么你将能够通过MAMP切换回旧的MySQL安装 -

sudo nano /etc/paths

然后将此行添加到文档的顶部 -

/Applications/MAMP/Library/bin

重新启动你的终端,然后运行mysql以仔细检查你是否正在使用MySQL的MAMP安装,你会很高兴.

1 个回答
  • 您是否考虑过使用自制软件安装MySQL(http://brew.sh/)?MAMP代表Mac-Apache-MySQL-PHP(其中最重要的部分是最重要的).我建议只在你的盒子上直接安装MySQL(自制软件负责所有繁重的工作),然后我怀疑你在安装这个宝石时遇到任何困难.

    安装自制软件 -

    ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
    

    brew doctor按照任何说明运行,然后安装MySQL运行brew install mysql并按照它为设置用户提供的任何说明等...

    =============更新==============

    那么,你想要做的就是使用brew这种方式来安装MySQL,然后以正常的方式安装gem - sudo gem install mysql2假设这有效,那么你将能够通过MAMP切换回旧的MySQL安装 -

    sudo nano /etc/paths
    

    然后将此行添加到文档的顶部 -

    /Applications/MAMP/Library/bin
    

    重新启动你的终端,然后运行mysql以仔细检查你是否正在使用MySQL的MAMP安装,你会很高兴.

    2023-02-06 13:59 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有