Solution - 'gem install mysql2' Fails

Today I spent some good hours to debug the issues while installing 'mysql2' gem. It was failing again and again stating that 'libmysql' not found (even after applying the solution I mentioned in previous blog). To share, I am mentioning all the steps from previous blog with today findings.

  1. Install 'MySQL' on your machine. Choose the installation depending upon your machine architecture i.e. 32 or 64 bits
  2. Have devkit installed on your machine. It can be download from ''
    1. Download right installer for your machine i.e. 32 or 64 bits
  3. Install devkit by following instructions at ''
  4. Go to <MySQL installation dir>/lib and copy the 'libmysql.dll' to <ruby installation dir>/bin
  5. Try running gem install mysql or mysql2
  6. It should install now. However, if you still face problem, follow steps given below
  7. Try specifying the --with-mysql-lib and --with-mysql-include options with gem command by specifying the mysql installation respective directories
  8. If it still fails to load the 'libmysql', ensure that you don't have space in the path of MySQL installation directory. 
  9. Simple solution could be to copy the lib and include folders to a simple path like C:/mysql and specify the path of include and lib folder with gem command using --with-mysql-lib and -include options
  10. Hopefully it should resolve the issue
Hope it will help. 

People who read this post also read :


Post a Comment