Search code examples
mysqlruby-on-railswindows-10

Having issues attaching ruby to mysql using the mysql2 gem


  • Rails version 6.0.4.6
  • Ruby Version 2.7.5p203
  • mySql version 8
  • OS Window 10

I am having issues getting the mysql2 gem to work. The latest error I have is not being able to locate "mysql2 x64-mingw32" file. I installed the gem using this command:

gem install mysql2 --platform=ruby -- --with-mysql-dir="C:\Program Files\MySQL\Connector C++ 8.0"
--with_mysql-lib="C:\Program Files\MySQL\Connector C++ 8.0\lib64" --with_mysql_include="C:\Program Files\MySQL\Connector C++ 8.0\include"

It appears to have been installed correctly but still will not work. I have run bundle install. I have also tried deleting the gem.lock file and the running bundle install.

If anyone has had success in getting ruby to work with MySQL on a Windows machine, please let me know how you did it.


Solution

  • After many trails, it appears the Ruby just doesn't play well with Windows OS. While I expect that some do use Ruby on Windows, it appears the support is lacking, and the community is small.

    I installed a Linux terminal on my machine and had much better luck.

    Just posting to keep other from pulling their hair out.