Gem install mysql error. How to install?

Decided to learn ruby. Honestly, the first acquaintance - not really! Now stuck on the following. Take a clean OS (tried Ubuntu 16 and 18 versions). Put ruby and database (tried MySQL and MariaDB). Trying to add support for MySQL in Ruby. And a complete failure!
apt update
apt install ruby-full
apt install mariadb-server
gem install mysql

error:
Fetching: mysql2-0.5.3.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
 ERROR: Failed to build gem native extension.

 current directory: /var/lib/gems/2.5.0/gems/mysql2-0.5.3/ext/mysql2
/usr/bin/ruby2.5-r ./siteconf20191211-3351-hskd8h.rb extconf.rb
checking for rb_absint_size()... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.

Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/bin/$(RUBY_BASE_NAME)2.5
/usr/lib/ruby/2.5.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (Runtime error)
You have to install development tools first.
 from /usr/lib/ruby/2.5.0/mkmf.rb:541:in `try_link0'
 from /usr/lib/ruby/2.5.0/mkmf.rb:559:in `try_link'
 from /usr/lib/ruby/2.5.0/mkmf.rb:770:in `try_func'
 from /usr/lib/ruby/2.5.0/mkmf.rb:1057:in `block in have_func'
 from /usr/lib/ruby/2.5.0/mkmf.rb:947:in `block in checking_for'
 from /usr/lib/ruby/2.5.0/mkmf.rb:350:in `block (2 levels) in postpone'
 from /usr/lib/ruby/2.5.0/mkmf.rb:320:in `open'
 from /usr/lib/ruby/2.5.0/mkmf.rb:350:in `block in postpone'
 from /usr/lib/ruby/2.5.0/mkmf.rb:320:in `open'
 from /usr/lib/ruby/2.5.0/mkmf.rb:346:in `postpone'
 from /usr/lib/ruby/2.5.0/mkmf.rb:946:in `checking_for'
 from /usr/lib/ruby/2.5.0/mkmf.rb:1056:in `have_func'
 from extconf.rb:25:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

/var/lib/gems/2.5.0/extensions/x86_64-linux/2.5.0/mysql2-0.5.3/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /var/lib/gems/2.5.0/gems/mysql2-0.5.3 for inspection.
Results logged to /var/lib/gems/2.5.0/extensions/x86_64-linux/2.5.0/mysql2-0.5.3/gem_make.out

Tried absolutely all the recipes that are on the Internet! build-essential zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-dev libncurses5-dev libffi-dev curl openssh-server redis-server checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev logrotate delivered! I have already spent a few days in the solution, and never succeed! In the network about such matters as much as ten years ago! Is it time this piece of shit hasn't fixed it yet!? It worked everywhere, no matter what I tried. In PHP, in Perl, in Windows, with its technology (and .Alien NET, and Delphi). I never in the beginning did not come across such a showstopper! How to overcome the problem then?
April 3rd 20 at 17:26
3 answers
April 3rd 20 at 17:28
1. And he MySQL you have installed? The fact that mysql gem is not quite a full-fledged client, it is rather a wrapper for the system library to work with MySQL.
2. Try to install a more modern library `gem install mysql2` and not `gem install mysql`.
3. How you installed Ruby itself? Through the Manager or native? Try to remove Ruby and install e.g. via RVM.
April 3rd 20 at 17:30
Try:
sudo apt-get install build-essential patch
sudo apt-get install ruby-dev zlib1g-dev liblzma-dev

Rubin is better to put using rbenv or rvm
April 3rd 20 at 17:32
1. Yes, like above I wrote! Muscul put this:
apt install mariadb-server
or this:
apt install mysql-server
tried different options. Because I ran across a post that he is starting with mysql version 5.7, there is something wrong and it would be nice to use Mary. But success is not led.
PS: I understand that this wrapper! Me that she need examples for ruby and SQL to try!
2. I forgot to add! gem install mysql2 also tried one of the solutions to the problem. For me it also changed nothing! (Except that the error is a little different).
3. Ruby put simply:
apt install ruby-full
initially did not want redundancy! No Rails, RVM and so I did not really need! However, in one embodiment, doing something like this:
gem install rails
It creaked for a long time brains, but in the end worked without errors. But, as the English say, of visas but paint! gem install mysql and did not work!

UPD1: once again, demolished all. On a clean Ubuntu installed gpg and mysql. Then rvm (for the user, without the gag). From the rvm installed ruby (again according to the instructions https://rvm.io/rvm/install). Again, try gem install mysql. The error now is this:
Building native extensions. This could take a while...
ERROR: Error installing mysql:
 ERROR: Failed to build gem native extension.

 current directory: /usr/share/rvm/gems/ruby-2.6.3/gems/mysql-2.9.1/ext/mysql_api
/usr/share/rvm/rubies/ruby-2.6.3/bin/ruby -I /usr/share/rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0 -r ./siteconf20191211-4210-8d232p.rb extconf.rb
checking for mysql_query() in-lmysqlclient... no
checking for-lm... yes
checking for mysql_query() in-lmysqlclient... no
checking for-lz... yes
checking for mysql_query() in-lmysqlclient... no
checking for-lsocket... no
checking for mysql_query() in-lmysqlclient... no
checking for-lnsl... yes
checking for mysql_query() in-lmysqlclient... no
checking for-lmygcc... no
checking for mysql_query() in-lmysqlclient... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.

Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/share/rvm/rubies/ruby-2.6.3/bin/$(RUBY_BASE_NAME)
--with-mysql-config
--without-mysql-config
--with-mysql-dir
--without-mysql-dir
--with-mysql-include
--without-mysql-include=${mysql-dir}/include
--with-mysql-lib
--without-mysql-lib=${mysql-dir}/lib
--with-mysqlclientlib
--without-mysqlclientlib
--with-mlib
--without-mlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-zlib
--without-zlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-socketlib
--without-socketlib
--with-mysqlclientlib
--without-mysqlclientlib
--with-nsllib
--without-nsllib
--with-mysqlclientlib
--without-mysqlclientlib
--with-mygcclib
--without-mygcclib
--with-mysqlclientlib
--without-mysqlclientlib

To see why this extension failed to compile, please check the mkmf.log which can be found here:

/usr/share/rvm/gems/ruby-2.6.3/extensions/x86_64-linux/2.6.0/mysql-2.9.1/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /usr/share/rvm/gems/ruby-2.6.3/gems/mysql-2.9.1 for inspection.
Results logged to /usr/share/rvm/gems/ruby-2.6.3/extensions/x86_64-linux/2.6.0/mysql-2.9.1/gem_make.out

He mkmf.log now under 100 KB. Don't know whether it makes sense here to put all of this?

UPD2: it's been a few days "exploring". The experiments done. No longer have the moral right to waste time on This. Life is not made of rubber! If it is simple things require such effort, then nafig nafig! This needs to be addressed when you have broken both legs and you lie in the hospital and you need to pass the time and in General is not much else to do. Pechalka!

UPD3: For the same poor fellows like me. mysql could not win, but mysql2 seems to win. So. Clean Ubuntu 18.04. Do:
apt update
apt install mc
apt install gpg
apt install mysql-server
gpg --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
apt-get install software-properties-common
apt-add-repository -y ppa:rael-gc/rvm
apt-get update
apt-get install rvm
reboot
rvm install ruby
apt install libmysqlclient-dev
gem install mysql2

Find more questions by tags RubyMySQLRuby gems