Widget HTML #1

Cara Install MariaDB/MySQL Database Server di Linux Red Hat 8

Database relasional bawaan Red Hat Enterprise Linux (RHEL) 8 telah diganti dari MySQL menjadi MariaDB. MariaDB adalah fork yang dikembangkan oleh komunitas dari database relasional MySQL dan merupakan pengganti MySQL.

Cara Menginstall MariaDB/MySQL Server

Untuk menginstall MariaDB Server kalian dapat menjalankan perintah:
# yum install mariadb-server

# yum install mariadb-server
Updating Subscription Management repositories.
Last metadata expiration check: 0:04:30 ago on Tue 16 Jul 2019 05:39:52 AM WIB.
Dependencies resolved.
 Package           Arch   Version        Repository                        Size
 mariadb-server    x86_64 3:10.3.11-2.module+el8+2885+7b8bb354
                                         rhel-8-for-x86_64-appstream-rpms  16 M
Installing dependencies:
                   noarch 3.0.7-1.el8    rhel-8-for-x86_64-appstream-rpms  13 k
 perl-libnet       noarch 3.11-3.el8     rhel-8-for-x86_64-appstream-rpms 121 k
 perl-Digest       noarch 1.17-395.el8   rhel-8-for-x86_64-appstream-rpms  27 k
 perl-URI          noarch 1.73-3.el8     rhel-8-for-x86_64-appstream-rpms 116 k
                   x86_64 3.0.7-1.el8    rhel-8-for-x86_64-appstream-rpms 148 k
 perl-Digest-MD5   x86_64 2.55-396.el8   rhel-8-for-x86_64-appstream-rpms  37 k
 perl-DBD-MySQL    x86_64 4.046-2.module+el8+2515+0650e81c
                                         rhel-8-for-x86_64-appstream-rpms 156 k
 perl-DBI          x86_64 1.641-2.module+el8+2701+8f20fb82
                                         rhel-8-for-x86_64-appstream-rpms 740 k
 perl-Net-SSLeay   x86_64 1.85-6.el8     rhel-8-for-x86_64-appstream-rpms 358 k
 mariadb-common    x86_64 3:10.3.11-2.module+el8+2885+7b8bb354
                                         rhel-8-for-x86_64-appstream-rpms  62 k
 mariadb-errmsg    x86_64 3:10.3.11-2.module+el8+2885+7b8bb354
                                         rhel-8-for-x86_64-appstream-rpms 232 k
 mariadb           x86_64 3:10.3.11-2.module+el8+2885+7b8bb354
                                         rhel-8-for-x86_64-appstream-rpms 6.2 M
                   x86_64 3:1.49-2.el8   rhel-8-for-x86_64-baseos-rpms     68 k
 perl-PathTools    x86_64 3.74-1.el8     rhel-8-for-x86_64-baseos-rpms     90 k
 perl-Data-Dumper  x86_64 2.167-399.el8  rhel-8-for-x86_64-baseos-rpms     58 k
 perl-libs         x86_64 4:5.26.3-416.el8
                                         rhel-8-for-x86_64-baseos-rpms    1.6 M
 perl-Errno        x86_64 1.28-416.el8   rhel-8-for-x86_64-baseos-rpms     76 k
 perl-interpreter  x86_64 4:5.26.3-416.el8
                                         rhel-8-for-x86_64-baseos-rpms    6.3 M
                   x86_64 1.58-2.el8     rhel-8-for-x86_64-baseos-rpms     48 k
 perl-Encode       x86_64 4:2.97-3.el8   rhel-8-for-x86_64-baseos-rpms    1.5 M
 perl-Socket       x86_64 4:2.027-2.el8  rhel-8-for-x86_64-baseos-rpms     59 k
                   x86_64 1.25-396.el8   rhel-8-for-x86_64-baseos-rpms     82 k
 perl-macros       x86_64 4:5.26.3-416.el8
                                         rhel-8-for-x86_64-baseos-rpms     72 k
 perl-MIME-Base64  x86_64 3.15-396.el8   rhel-8-for-x86_64-baseos-rpms     31 k
 perl-threads      x86_64 1:2.21-2.el8   rhel-8-for-x86_64-baseos-rpms     61 k
 perl-Pod-Simple   noarch 1:3.35-395.el8 rhel-8-for-x86_64-baseos-rpms    213 k
                   noarch 4.06-396.el8   rhel-8-for-x86_64-baseos-rpms     46 k
 perl-Math-Complex noarch 1.59-416.el8   rhel-8-for-x86_64-baseos-rpms    108 k
 perl-HTTP-Tiny    noarch 0.074-1.el8    rhel-8-for-x86_64-baseos-rpms     58 k
 perl-Pod-Escapes  noarch 1:1.07-395.el8 rhel-8-for-x86_64-baseos-rpms     20 k
 perl-Pod-Perldoc  noarch 3.28-396.el8   rhel-8-for-x86_64-baseos-rpms     88 k
 psmisc            x86_64 23.1-3.el8     rhel-8-for-x86_64-baseos-rpms    150 k
 perl-Math-BigInt  noarch 1:1.9998.11-5.el8
                                         rhel-8-for-x86_64-baseos-rpms    195 k
 perl-File-Path    noarch 2.15-2.el8     rhel-8-for-x86_64-baseos-rpms     38 k
 perl-parent       noarch 1:0.237-1.el8  rhel-8-for-x86_64-baseos-rpms     20 k
 perl-IO           x86_64 1.38-416.el8   rhel-8-for-x86_64-baseos-rpms    141 k
                   noarch 2013.0523-395.el8
                                         rhel-8-for-x86_64-baseos-rpms     24 k
 perl-Getopt-Long  noarch 1:2.50-4.el8   rhel-8-for-x86_64-baseos-rpms     63 k
 perl-podlators    noarch 4.11-1.el8     rhel-8-for-x86_64-baseos-rpms    118 k
 perl-Time-Local   noarch 1:1.280-1.el8  rhel-8-for-x86_64-baseos-rpms     34 k
 perl-Carp         noarch 1.42-396.el8   rhel-8-for-x86_64-baseos-rpms     30 k
 perl-Exporter     noarch 5.72-396.el8   rhel-8-for-x86_64-baseos-rpms     34 k
 perl-Storable     x86_64 1:3.11-3.el8   rhel-8-for-x86_64-baseos-rpms     98 k
                   noarch 3.30-395.el8   rhel-8-for-x86_64-baseos-rpms     18 k
 perl-File-Temp    noarch 0.230.600-1.el8
                                         rhel-8-for-x86_64-baseos-rpms     63 k
 perl-constant     noarch 1.33-396.el8   rhel-8-for-x86_64-baseos-rpms     25 k
 perl-Term-Cap     noarch 1.17-395.el8   rhel-8-for-x86_64-baseos-rpms     23 k
 perl-Pod-Usage    noarch 4:1.69-395.el8 rhel-8-for-x86_64-baseos-rpms     34 k
Installing weak dependencies:
 perl-Mozilla-CA   noarch 20160104-7.el8 rhel-8-for-x86_64-appstream-rpms  15 k
 perl-IO-Socket-IP noarch 0.39-5.el8     rhel-8-for-x86_64-appstream-rpms  47 k
                   noarch 2.060-2.el8    rhel-8-for-x86_64-appstream-rpms 289 k
                   x86_64 3:10.3.11-2.module+el8+2885+7b8bb354
                                         rhel-8-for-x86_64-appstream-rpms  49 k
                   x86_64 3:10.3.11-2.module+el8+2885+7b8bb354
                                         rhel-8-for-x86_64-appstream-rpms 1.6 M
 mariadb-backup    x86_64 3:10.3.11-2.module+el8+2885+7b8bb354
                                         rhel-8-for-x86_64-appstream-rpms 6.2 M
Enabling module streams:
 mariadb                  10.3                                                 
 perl-DBD-MySQL           4.046                                                
 perl-DBI                 1.641                                                

Transaction Summary
Install  55 Packages

Total download size: 44 M
Installed size: 201 M
Is this ok [y/N]: y

Masukkan (y) lalu tekan tombol Enter, dan tunggu proses install MariaDB Server selesai.

Bagaimana Cara Start dan Enable MariaDB supaya otomatis berjalan saat Booting

# systemctl start mariadb
# systemctl enable mariadb

Untuk melihat status dari service mariadb, jalankan perintah berikut ini:
# systemctl status mariadb

Status MariaDB Database Server Running

Pengaturan Keamanan (secure) MariaDB Database Server dan Mengubah Password Root

Untuk melakukan pengaturan keamanan MariaDB Database Server, jalankan perintah berikut ini:
# mysql_secure_installation

Kalian akan diberi beberapa pertanyaan tentang instalasi MariaDB kalian dan bagaimana kalian ingin mengamankannya. Kalian juga dapat mengubah kata sandi (password) pengguna root basis data, menonaktifkan basis data test, menonaktifkan pengguna anonim, dan menonaktifkan login root via remote atau jarak jauh.

# mysql_secure_installation


In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] Y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] Y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] Y
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] Y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] Y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

Menampilkan Informasi Database di MariaDB Server

Setelah pengaturan keamanan selesai, kalian dapat terhubung ke MariaDB/MySQL dan dapat melihat database yang ada dengan menjalankan perintah:
# mysql -e "SHOW DATABASES;" -p

Masukkan password root sesuai dengan yang kalian masukkan pada saat kalian mengamankan MariaDB/MySQL.

# mysql -e "SHOW DATABASES;" -p
Enter password: 
| Database           |
| information_schema |
| mysql              |
| performance_schema |

Sampai di sini proses installasi MariaDB/MySQL di Red Hat Enterprise Linux 8 selesai, jika ada pertanyaan silahkan mengisi kolom komentar di bawah postingan ini.