GNU/Linux >> Belajar Linux >  >> Cent OS

Cara Menginstal Server Database MySQL 8 di CentOS 8

MySQL adalah gratis, open-source dan salah satu sistem database yang paling populer di seluruh dunia. Ini adalah platform manajemen basis data relasional yang didukung oleh Oracle Cloud. Ini menggunakan Bahasa Kueri Terstruktur untuk menambahkan, mengakses, dan mengelola konten dalam database. Ia dikenal karena keandalannya yang telah terbukti, pemrosesan yang cepat, kemudahan, dan fleksibilitas penggunaan. Ada beberapa fitur baru yang telah ditambahkan di MySQL 8 termasuk, dukungan JSON, Kamus Data Transaksional, konfigurasi runtime persisten, Penyimpanan Dokumen, Petunjuk Pengoptimal, peran SQL, fungsi CTE dan Jendela, indeks Tak Terlihat dan banyak lagi.

Catatan :Sebelum menginstal MySQL 8, lihat dokumentasi resmi karena MySQL 8 memiliki beberapa fitur dan perubahan baru yang membuat beberapa aplikasi tidak kompatibel dengan versi ini.

Dalam tutorial ini, kami akan menunjukkan cara menginstal database MySQL 8 di server CentOS 8.

Prasyarat

  • Server yang menjalankan CentOS 8.
  • Kata sandi root disiapkan di server Anda.

Instal MySQL 8.0 dari Repositori MySQL

Secara default, MySQL 8.0 tidak tersedia di repositori default CentOS 8. Jadi, Anda perlu menginstal repositori komunitas MySQL 8.0 ke sistem Anda. Anda dapat menginstalnya dengan perintah berikut:

rpm -ivh https://dev.mysql.com/get/mysql80-community-release-el8-1.noarch.rpm

Anda akan melihat output berikut:

Retrieving https://dev.mysql.com/get/mysql80-community-release-el8-1.noarch.rpm
warning: /var/tmp/rpm-tmp.hF0m5V: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Verifying...                          ################################# [100%]
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql80-community-release-el8-1  ################################# [100%]

Selanjutnya, verifikasi apakah repositori MySQL 8.0 telah diaktifkan atau belum dengan perintah berikut:

dnf repolist all | grep mysql | grep enabled

Anda akan melihat output berikut:

CentOS-8 - AppStream                            3.1 MB/s | 6.5 MB     00:02    
CentOS-8 - Base                                 3.0 MB/s | 5.0 MB     00:01    
CentOS-8 - Extras                               5.3 kB/s | 2.1 kB     00:00    
MySQL 8.0 Community Server                       24 MB/s | 543 kB     00:00    
MySQL Connectors Community                      1.9 MB/s |  19 kB     00:00    
MySQL Tools Community                           677 kB/s |  62 kB     00:00    
mysql-connectors-community         MySQL Connectors Community     enabled:    42
mysql-tools-community              MySQL Tools Community          enabled:    19
mysql80-community                  MySQL 8.0 Community Server     enabled:    31

Selanjutnya, nonaktifkan repositori AppStream untuk sementara dan instal versi terbaru MySQL 8.0 dari repositori komunitas MySQL dengan perintah berikut:

dnf --disablerepo=AppStream install mysql-community-server -y

Setelah instalasi berhasil diselesaikan, Anda dapat memverifikasi versi MySQL yang diinstal dengan perintah berikut:

mysql -Version

Anda akan melihat output berikut:

mysql  Ver 8.0.19 for Linux on x86_64 (MySQL Community Server - GPL)

Selanjutnya, mulai layanan MySQL dan aktifkan untuk memulai setelah sistem reboot dengan perintah berikut:

systemctl start mysqld
systemctl enable mysqld

Anda juga dapat memeriksa status MySQL dengan perintah berikut:

systemctl status mysqld

Anda akan melihat output berikut:

? mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2020-03-05 09:37:46 EST; 12s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 3244 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 3329 (mysqld)
   Status: "Server is operational"
    Tasks: 39 (limit: 12537)
   Memory: 587.7M
   CGroup: /system.slice/mysqld.service
           ??3329 /usr/sbin/mysqld

Mar 05 09:37:01 centos8 systemd[1]: Starting MySQL Server...
Mar 05 09:37:46 centos8 systemd[1]: Started MySQL Server.

Selanjutnya, selalu merupakan ide yang baik untuk menjalankan skrip mysql_secure_installation untuk mengaktifkan beberapa fitur keamanan tambahan termasuk, menyetel kata sandi root MySQL baru, menghapus pengguna anonim dan menonaktifkan login jarak jauh.

Pertama, temukan kata sandi root default MySQL menggunakan perintah berikut:

cat /var/log/mysqld.log | grep -i 'temporary password'

Keluaran:

2020-03-05T14:37:40.273796Z 5 [Note] [MY-010454] [Server] A temporary password is generated for [email protected]: GN2uNx-vPqwS

Harap perhatikan kata sandi di atas dan ubah menggunakan skrip mysql_secure_installation.

mysql_secure_installation

Jawab semua pertanyaan seperti yang ditunjukkan di bawah ini:

Securing the MySQL server deployment.

Enter password for user root:   Provide your temporary MySQL root password

The existing password for the user account root has expired. Please set a new password.

New password:   Provide new root password

Re-enter new password:   Re-enter new root password
The 'validate_password' component is installed on the server.
The subsequent steps will run with the existing configuration
of the component.
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) : N  Type N and Enter to continue

 ... skipping.
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!

Instal MySQL 8.0 dari Repositori AppStream

Anda juga dapat menginstal MySQL 8.0 dari repositori AppStream default pada CentOS 8. Anda dapat menginstalnya dengan perintah berikut:

dnf install @mysql -y

Setelah instalasi selesai, periksa versi MySQL dengan perintah berikut:

mysql -Version

Anda akan melihat output berikut:

mysql  Ver 8.0.17 for Linux on x86_64 (Source distribution)

Selanjutnya, mulai layanan MySQL dan aktifkan untuk memulai setelah sistem reboot dengan perintah berikut:

systemctl start mysqld
systemctl enable mysqld

Secara default, kata sandi root MySQL tidak diatur di CentoS 8. Jadi, Anda perlu mengaturnya menggunakan skrip mysql_secure_installation.

mysql_secure_installation

Jawab semua pertanyaan seperti yang ditunjukkan di bawah ini:

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?

Press y|Y for Yes, any other key for No: Y

There are three levels of password validation policy:

LOW    Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary                  file

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 0
Please set the password for root here.

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! 

Kesimpulan

Dalam panduan di atas, Anda mempelajari cara menginstal MySQL 8 dari repositori komunitas MySQL dan dari repositori AppStream di CentOS 8. Sekarang Anda dapat mulai membuat database dan pengguna database baru.


Cent OS
  1. Bagaimana cara menginstal wordpress di CentOS 6

  2. Instal MySQL Server 5.6 di CentOS

  3. Cara Menginstal Mediawiki di Server CentOS

  1. Cara Menginstal Server Percona di CentOS 7

  2. Cara Menginstal MySQL 8.0 di CentOS/RHEL 8

  3. Cara Menginstal Server Database MySQL di CentOS

  1. Cara Menginstal Mtop (Pemantauan Server Database MySQL) di CentOS 6

  2. Cara Instal Server MySQL di CentOS 7

  3. Cara Menginstal MySQL 5.6 di CentOS 6.x