Instalasi MySQL 5.7 Pada CentOS 7 Dan Fedora 36/35

HomelinuxCentos

Instalasi MySQL 5.7 Pada CentOS 7 Dan Fedora 36/35

MySQL Community telah merilis MySQL 5.7. Ini tersedia di situs web resmi MySQL. Artikel ini akan membantu Anda menginstal MySQL Server 5.7 pada sistem CentOS 6 dan Fedora Anda.

Langkah 1 – Aktifkan Repositori MySQL

Pertama-tama, Anda harus mengaktifkan repositori yum rilis komunitas MySQL 5.7 di sistem Anda. Paket rpm untuk konfigurasi repositori yum tersedia di situs web resmi MySQL.

Pertama-tama, impor kunci MySQL GPG terbaru ke sistem Anda.

$ sudo rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022

Sekarang, gunakan salah satu perintah di bawah ini untuk mengonfigurasi repositori Yum sesuai versi sistem operasi Anda.

CentOS & RHEL 7:

$ sudo yum localinstall https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm

Fedora 36

$ dnf install https://dev.mysql.com/get/mysql57-community-release-fc27-11.noarch.rpm

Fedora 35

$ sudo dnf install https://dev.mysql.com/get/mysql57-community-release-fc26-11.noarch.rpm

Langkah 2 – Menginstal Server MySQL 5.7

Setelah berhasil mengaktifkan repositori MySQL yum di sistem Anda. Sekarang, melanjutkan proses instalasi MySQL Community Server 5.7 menggunakan perintah berikut sesuai versi sistem operasi Anda.

CentOS & RHEL 7:

$ sudo yum install mysql-community-server

Fedora 36/35:

$ sudo dnf install mysql-community-server

Perintah di atas akan menginstal MySQL Community Server 5.7 beserta dependensi lainnya di sistem Anda. Selama proses instalasi paket, kata sandi sementara dibuat dan dicatat ke file log MySQL. Gunakan perintah berikut untuk menemukan kata sandi MySQL sementara Anda.

Setelah menginstal RPM, gunakan perintah berikut untuk memulai Layanan MySQL.

$ sudo systemctl start mysqld

Saat proses instalasi, MySQL menyimpan kata sandi akun root di file log, kata sandi dapat ditemukan dengan perintah berikut.

$ grep 'A temporary password' /var/log/mysqld.log |tail -1

Contoh Output :

2017-03-30T02:57:10.981502Z 1 [Note] A temporary password is generated for root@localhost: Nm(!pKkkjo68e

Langkah 4 – Konfigurasi Awal MySQL

Jalankan skrip mysql_secure_installation dan ikuti wizard. Ini akan meminta kata sandi root. Gunakan kata sandi root sementara yang didapat pada langkah di atas.

$ /usr/bin/mysql_secure_installation

Di langkah awal akan meminta Anda untuk memasukkan kata sandi password untuk akun root MySQL. Untuk opsi yang tersisa.

Securing the MySQL server deployment.

Enter password for user root: **********

The 'validate_password' plugin is installed on the server.
The subsequent steps will run with the existing configuration
of the plugin.
Using existing password for root.

Estimated strength of the password: 100
Change the password for root ? ((Press y|Y for Yes, any other key for No) : y

New password: ******************

Re-enter new password: ******************

Estimated strength of the password: 100
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL 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? (Press y|Y for Yes, any other key for No) : 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? (Press y|Y for Yes, any other key for No) : y
Success.

By default, MySQL 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? (Press y|Y for Yes, any other key for No) : 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? (Press y|Y for Yes, any other key for No) : y
Success.

All done!

Langkah 5 – Masuk ke MySQL

Selamat! Anda telah berhasil menginstal MySQL 5.7. Biarkan login ke MySQL menggunakan akses root dan coba buat database dummy. Gunakan kata sandi yang telah Anda tetapkan untuk Langkah #4.

$ mysql -u root -p

Contoh Output :

Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.38 MySQL Community Server (GPL)

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

Langkah 6 – Periksa Versi MySQL

Verifikasi versi MySQL Anda yang terinstal di sistem Anda. Perintah berikut akan menampilkan versi MySQL yang diinstal.

$ mysql -V

Contoh output :

mysql Ver 14.14 Distrib 5.7.38, for Linux (x86_64) using EditLine wrapper