无法安装 mysql2

无法安装 mysql2

我尝试mysql使用以下命令进行安装

gem install mysql2 -v '0.3.18'

但是我收到了以下错误

    Fetching: mysql2-0.3.18.gem (100%)
    Building native extensions.  This could take a while...
    ERROR:  Error installing mysql2:
        ERROR: Failed to build gem native extension.

        /home/jophy/.rvm/rubies/ruby-2.2.1/bin/ruby -r ./siteconf20170221-7481-38xom2.rb extconf.rb

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.

当我打开时mkmf.log,我发现以下错误:-

/usr/bin/ld: cannot find -lmysqlclient
collect2: error: ld returned 1 exit status

答案1

作为@steeldriver在他的评论中提到,你需要安装libmysqlclient-dev 包它适用于从 Precise 到 Zesty 的所有当前支持的 Ubuntu 版本,可以通过软件中心或 CLI(终端)使用以下命令进行安装sudo apt-get install libmysqlclient-dev

资料来源:

无法安装 mysql2

https://stackoverflow.com/questions/27832120/error-error-installing-mysql2-error-failed-to-build-gem-native-extension

相关内容