How To Install rubygem-mysql2 on CentOS 8

rubygem-mysql2 is A simple, fast Mysql library for Ruby, binding to libmysql

Introduction

In this tutorial we learn how to install rubygem-mysql2 on CentOS 8.

What is rubygem-mysql2

The Mysql2 gem is meant to serve the extremely common use-case of connecting, querying and iterating on results. Some database libraries out there serve as direct 1 available. This one is not.

We can use yum or dnf to install rubygem-mysql2 on CentOS 8. In this tutorial we discuss both methods but you only need to choose one of method to install rubygem-mysql2.

Install rubygem-mysql2 on CentOS 8 Using dnf

Update yum database with dnf using the following command.

sudo dnf makecache --refresh

The output should look something like this:

CentOS Linux 8 - AppStream                                       43 kB/s | 4.3 kB     00:00    
CentOS Linux 8 - BaseOS                                          65 kB/s | 3.9 kB     00:00    
CentOS Linux 8 - ContinuousRelease                               43 kB/s | 3.0 kB     00:00    
CentOS Linux 8 - Extras                                          23 kB/s | 1.5 kB     00:00    
CentOS Linux 8 - FastTrack                                       40 kB/s | 3.0 kB     00:00    
CentOS Linux 8 - HighAvailability                                36 kB/s | 3.9 kB     00:00    
CentOS Linux 8 - Plus                                            24 kB/s | 1.5 kB     00:00    
CentOS Linux 8 - PowerTools                                      50 kB/s | 4.3 kB     00:00    
Extra Packages for Enterprise Linux Modular 8 - x86_64           13 kB/s | 9.2 kB     00:00    
Extra Packages for Enterprise Linux 8 - x86_64                   24 kB/s | 8.5 kB     00:00    
Metadata cache created.

After updating yum database, We can install rubygem-mysql2 using dnf by running the following command:

sudo dnf -y install rubygem-mysql2

Install rubygem-mysql2 on CentOS 8 Using yum

Update yum database with yum using the following command.

sudo yum makecache --refresh

The output should look something like this:

CentOS Linux 8 - AppStream                                       43 kB/s | 4.3 kB     00:00    
CentOS Linux 8 - BaseOS                                          65 kB/s | 3.9 kB     00:00    
CentOS Linux 8 - ContinuousRelease                               43 kB/s | 3.0 kB     00:00    
CentOS Linux 8 - Extras                                          23 kB/s | 1.5 kB     00:00    
CentOS Linux 8 - FastTrack                                       40 kB/s | 3.0 kB     00:00    
CentOS Linux 8 - HighAvailability                                36 kB/s | 3.9 kB     00:00    
CentOS Linux 8 - Plus                                            24 kB/s | 1.5 kB     00:00    
CentOS Linux 8 - PowerTools                                      50 kB/s | 4.3 kB     00:00    
Extra Packages for Enterprise Linux Modular 8 - x86_64           13 kB/s | 9.2 kB     00:00    
Extra Packages for Enterprise Linux 8 - x86_64                   24 kB/s | 8.5 kB     00:00    
Metadata cache created.

After updating yum database, We can install rubygem-mysql2 using yum by running the following command:

sudo yum -y install rubygem-mysql2

How To Uninstall rubygem-mysql2 on CentOS 8

To uninstall only the rubygem-mysql2 package we can use the following command:

sudo dnf remove rubygem-mysql2

rubygem-mysql2 Package Contents on CentOS 8

/usr/lib/.build-id
/usr/lib/.build-id/e4
/usr/lib/.build-id/e4/cb22c89135f92c8373c6b50cb3cce0bca356dd
/usr/lib64/gems/ruby/mysql2-0.4.10
/usr/lib64/gems/ruby/mysql2-0.4.10/gem.build_complete
/usr/lib64/gems/ruby/mysql2-0.4.10/gem_make.out
/usr/lib64/gems/ruby/mysql2-0.4.10/mkmf.log
/usr/lib64/gems/ruby/mysql2-0.4.10/mysql2
/usr/lib64/gems/ruby/mysql2-0.4.10/mysql2/mysql2.so
/usr/share/gems/gems/mysql2-0.4.10
/usr/share/gems/gems/mysql2-0.4.10/LICENSE
/usr/share/gems/gems/mysql2-0.4.10/lib
/usr/share/gems/gems/mysql2-0.4.10/lib/mysql2
/usr/share/gems/gems/mysql2-0.4.10/lib/mysql2.rb
/usr/share/gems/gems/mysql2-0.4.10/lib/mysql2/client.rb
/usr/share/gems/gems/mysql2-0.4.10/lib/mysql2/console.rb
/usr/share/gems/gems/mysql2-0.4.10/lib/mysql2/em.rb
/usr/share/gems/gems/mysql2-0.4.10/lib/mysql2/error.rb
/usr/share/gems/gems/mysql2-0.4.10/lib/mysql2/field.rb
/usr/share/gems/gems/mysql2-0.4.10/lib/mysql2/result.rb
/usr/share/gems/gems/mysql2-0.4.10/lib/mysql2/statement.rb
/usr/share/gems/gems/mysql2-0.4.10/lib/mysql2/version.rb
/usr/share/gems/specifications/mysql2-0.4.10.gemspec

References

Summary

In this tutorial we learn how to install rubygem-mysql2 on CentOS 8 using yum and dnf.