Ubuntu 升级到12.04引起的MySQL错误


Ubuntu 12.04中将MySQL升级到5.5.22导致原先的MySQL加载失败

解决方法:

1.完全卸载原先的MySQL

  1. sudo apt-get remove mysql-server   
  2. sudo apt-get autoremove --purge mysql-server   
  3. sudo apt-get remove mysql-common(这步比较重要)   
  4. dpkg -l | grep ^rc | awk '{print $2}' | sudo xargs dpkg -P  

2.重新安装mysql(安装前最好重启)

sudo apt-get install mysql-server  
sudo apt-get install mysql-workbench(原先的client无法使用) 

可使用以下命令检查是否安装成功

sudo netstat -tap | grep mysql 

3.原先gem中的mysql2需要重新编译安装

  1. gem uninstall mysql2   
  2. gem install mysql2  

4.安装mysql2时可能出现以下错误

  1. Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.   
  2.   
  3. /homexxx/.rbenv/versions/1.9.3-p125/bin/ruby extconf.rb    
  4. checking for rb_thread_blocking_region()... yes   
  5. checking for rb_wait_for_single_fd()... yes   
  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... yes   
  14. checking for mysql_query() in -lmysqlclient... no   
  15. checking for main() in -lmygcc... no   
  16. checking for mysql_query() in -lmysqlclient... no   
  17. *** extconf.rb failed ***   
  18. Could not create Makefile due to some reason, probably lack of   
  19. necessary libraries and/or headers.  Check the mkmf.log file for more   
  20. details.  You may need configuration options.  

解决方法:

  1. sudo apt-get install libmysql-ruby   
  2. sudo apt-get install libmysqlclient-dev   
  3. gem install mysql  

更多Ubuntu相关信息见Ubuntu 专题页面 http://www.bkjia.com/topicnews.aspx?tid=2

相关内容