MySQL Install: ERROR: Failed to build gem native extension

前端 未结 14 1680
天涯浪人
天涯浪人 2020-11-28 19:23

I\'m trying to get MySQL installed to the latest version due to some installation going wrong somewhere along the line. I run the command gem install mysql and

相关标签:
14条回答
  • 2020-11-28 20:14

    If you use Percona Mysql server

    $ yum install Percona-Server-devel-55

    $ gem install mysql

    0 讨论(0)
  • 2020-11-28 20:21

    First of all you need to differentiate between the MySQL as Server, MySQL as Client and the Ruby bindings to MySQL.

    I'm not familiar with Mac, but for *nix OS you need to install MySQL through your package manager. To get the Ruby bindings installed with

    gem install mysql
    

    you need the development headers of ruby (in Ubuntu it is the package ruby-dev) and the development headers of the MySQL-Client (currently libmysqlclient16-dev in Ubuntu). I don't know if they are named different on Mac, but after you got those installed the Ruby bindings should install without any error.

    0 讨论(0)
  • 2020-11-28 20:21

    I had a similar experience, so here are the things that I tried

    Firstly, I tried to install mysql's required packages by running the command below in my terminal

    sudo apt-get install build-essential libmysqlclient-dev
    

    Secondly, I tried updating rubygems on my system by running the command below in my terminal

    sudo gem update --system
    

    But I was still experiencing the same issue. After much research I realized that I was using an almost out-of-date version of the mysql gem. I simply needed to use the mysql2 gem (mysql2 gem)and not the mysql gem, so I fixed it by running the command below in my terminal

    gem install mysql2
    

    This worked fine for me. Before running the last command, ensure that you've ran the first and second commands to be sure that everything is fine on your system.

    That's all.

    I hope this helps

    0 讨论(0)
  • 2020-11-28 20:23

    Attention: You need to specify -- key, and than --with-mysql-config=/usr/local/mysql/bin/mysql_config

    0 讨论(0)
  • 2020-11-28 20:24

    you can try to reinstall the latest version of xcode / dev. tools for snow leopard - this should fix your errors

    0 讨论(0)
  • 2020-11-28 20:25

    Installing the mysql gem on OSX

    in a terminal.. First do a ‘locate mysql_config’ and then replace the path in the following command with where that file is.

    $ sudo gem install mysql -- —–with-mysql-config=/usr/local/mysql/bin/mysql_config
    Building native extensions. This could take a while…
    Successfully installed mysql-2.7
    1 gem installed
    
    0 讨论(0)
提交回复
热议问题