Installing the mysql2 Ruby Gem on Windows using MariaDB
When I tried installing the mysql2 on Windows I had a terrible time. I was getting warnings and errors that other people didn't seem to get.
current directory: C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/mysql2-0.5.4/ext/mysql2
make DESTDIR\= sitearchdir\=./.gem.20230120-3824-fia970 sitelibdir\=./.gem.20230120-3824-fia970
gcc.exe: error: unrecognized command-line option '-Weverything'
make: *** [Makefile:247: client.o] Error 1
Here's how to fix the "-Weverything" error.
Allows you to install MariaDB/mysql2 gem on Windows.
1. Downloaded MariaDB off the official website and installed it.
2. Run this command:
gem install mysql2 --platform=ruby -- --with-mysql-lib=C:\Program Files\MariaDB 10.6\ --with-mysql-dir=C:\Ruby31-x64\msys64\mingw64
What is the mysql2 gem?
mysql2 is a Ruby gem that provides a Ruby interface to the MySQL database. It is a database adapter that allows Ruby on Rails applications to communicate with a MySQL database. The mysql2 gem is a replacement for an older mysql gem, and it is faster and more feature-rich than its predecessor. It is commonly used in Ruby on Rails applications to interact with MySQL databases. It has been in use for more than a decade now.
What is MariaDB?
MariaDB is an open-source relational database management system that is a fork of the MySQL database. It was created by the original developers of MySQL, when MySQL was acquired by Oracle Corporation. MariaDB is intended to maintain high compatibility with MySQL, so that it can be a drop-in replacement for it. Some key features of MariaDB include support for advanced data types, better performance and scalability, and improved security. MariaDB is widely used in Linux distributions, and it is considered a popular alternative to MySQL.
Many features that you can only get with a paid version of MySQL can be found for free in MariaDB.
Why was this hard?
The gcc compiler has chosen not to support the "-Weverything" option. The compile maintainers are lazy in my opinion because it didn't fit their specific use cases.