[英]ERROR: Error installing mysql2: ERROR: Failed to build gem native extension
I am having some problems when trying to install gem install mysql2 -v '0.3.17' for Rails. 我在尝试为Rails安装gem install mysql2 -v'0.3.17'时遇到了一些问题。 When I try to install it by running gem install mysql2 -v '0.3.17' or gem install mysql2 -v '0.3.17' it gives me the following error:
当我尝试通过运行gem install mysql2 -v'0.3.17'或gem install mysql2 -v'0.3.17'来安装它时,它给出了以下错误:
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--with-mysql-dir
--without-mysql-dir
--with-mysql-include
--without-mysql-include=${mysql-dir}/include
--with-mysql-lib
--without-mysql-lib=${mysql-dir}/lib
--with-mysql-config
--without-mysql-config
Gem files will remain installed in `..../gems/ruby-1.9.3-p392/gems/mysql2-0.3.17 for inspection`.
Results logged to `.../gems/ruby-1.9.3-p392/extensions/x86_64-darwin-14/1.9.1/mysql2-0.3.17/gem_make.out`
How can I fix this and successfully install mysql2? 我该如何解决这个问题并成功安装mysql2?
Thanks all . 谢谢大家。
I am in Ubuntu 15.04 and I got the same error as stated above. 我在Ubuntu 15.04,我得到了与上述相同的错误。
I did : 我做了:
sudo apt-get install libmysqlclient-dev
After this I did: 在此之后我做了:
gem install mysql2
And now I can successfully do 而现在我可以成功地做到
rails new <app_name> -d mysql
without any errors. 没有任何错误。
Install libmysqlclient-devel: 安装libmysqlclient-devel:
CentOS/Fedora: CentOS的/ Fedora的:
yum install -y libmysqlclient-devel
Ubuntu: Ubuntu的:
apt-get install -y libmysqlclient-dev
Mac: 苹果电脑:
brew install mysql
Hope it helps. 希望能帮助到你。
hi this might be happening for two reason. 嗨,这可能是因为两个原因。
1) You did not install your mysql server for that try 1)您没有为该尝试安装mysql服务器
$ brew install mysql
2) didn't specified mysql_config when you are trying to install mysql2 for this try with 2)当您尝试为此尝试安装mysql2时未指定mysql_config
$ gem install mysql2 -- --with-mysql-config=/usr/local/Cellar/mysql/5.6.24/bin/mysql_config
You need to install MySQL server first. 您需要先安装MySQL服务器。 You probably don't have it at the moment.
你现在可能没有它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.