无法在Mac Os下通过Gem安装Mysql

在Mac Os下通过Gem安装Mysql时,老是报错:

Java代码 复制代码 收藏代码
  1. Building native extensions.  This could take a while...   
  2. ERROR:  Error installing mysql:   
  3.     ERROR: Failed to build gem native extension.   
  4.   
  5.         /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb   
  6. checking for mysql_query() in -lmysqlclient... no   
  7. checking for main() in -lm... yes   
  8. checking for mysql_query() in -lmysqlclient... no   
  9. checking for main() in -lz... yes   
  10. checking for mysql_query() in -lmysqlclient... no   
  11. checking for main() in -lsocket... no   
  12. checking for mysql_query() in -lmysqlclient... no   
  13. checking for main() in -lnsl... no   
  14. checking for mysql_query() in -lmysqlclient... no   
  15. checking for main() in -lmygcc... no   
  16. checking for mysql_query() in -lmysqlclient... no  

 貌似是缺少了某些文件导致的,于是看了看/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb发现extconf.rb好像需要Mysql的PATH,于是执行:

Java代码 复制代码 收藏代码
  1. export PATH=$PATH:/usr/local/mysql/bin   
  2. sudo gem install mysql -v '2.8.1'  

 

问题解决:

Java代码 复制代码 收藏代码
  1. Building native extensions.  This could take a while...   
  2. Successfully installed mysql-2.8.1  
  3. 1 gem installed   
  4. Installing ri documentation for mysql-2.8.1...   
  5. Installing RDoc documentation for mysql-2.8.1...  
原文地址:https://www.cnblogs.com/bjanzhuo/p/3576116.html