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

Cara Instal MySQL 8.0/5.7 di CentOS 7 / RHEL 7

MySQL adalah sistem manajemen basis data sumber terbuka dan gratis, umumnya digunakan dalam aplikasi web untuk menyimpan dan mengambil catatan dan informasi.

MySQL awalnya dikembangkan oleh MYSQL AB, sekarang dimiliki oleh Oracle Corporation. Itu adalah aplikasi database utama untuk sistem operasi Linux sampai MariaDB, sebuah fork dari MySQL, muncul.

Pada artikel ini, kita akan melihat cara menginstal MySQL 8.0/5.7 di CentOS 7 / RHEL 7.

Tambahkan Repositori MySQL

MySQL tidak lagi didistribusikan melalui repositori OS. Jadi, Anda perlu menambahkan repositori resmi MySQL untuk menginstal server komunitas MySQL.

rpm -ivh https://dev.mysql.com/get/mysql80-community-release-el7-4.noarch.rpm

Pastikan repositori MySQL telah ditambahkan dan diaktifkan dengan menggunakan perintah berikut.

yum repolist all | grep mysql | grep enabled

Output:Mungkin Terlihat seperti.

mysql-connectors-community/x86_64   MySQL Connectors Community   enabled:    221
mysql-tools-community/x86_64        MySQL Tools Community        enabled:    135
mysql80-community/x86_64            MySQL 8.0 Community Server   enabled:    301

Instal Server Komunitas MySQL

Oracle saat ini menawarkan kedua versi stabil (v8.0 dan v5.7). Anda dapat memilih salah satu yang ingin Anda instal di mesin Anda.

Instal MySQL 8.0

Gunakan perintah yum untuk menginstal server komunitas MySQL 8.0.

yum install -y mysql-community-server

Instal MySQL 5.7

Jika Anda ingin mencoba MySQL versi lama, instal MySQL 5.7 di komputer Anda dengan perintah di bawah ini.

yum install -y mysql-community-server --disablerepo=mysql80-community --enablerepo=mysql57-community

Setelah instalasi MySQL, Anda dapat memulai server MySQL menggunakan perintah berikut.

systemctl start mysqld

Kemudian, aktifkan layanan MySQL untuk memulai secara otomatis saat startup sistem.

systemctl enable mysqld

Terakhir, verifikasi apakah server MySQL mulai menggunakan perintah berikut.

systemctl status mysqld

Kata Sandi Root MySQL Awal

Di CentOS/RHEL, Anda dapat menemukan kata sandi root MySQL awal di /var/log/mysqld.log . Anda dapat menggunakan perintah di bawah ini untuk mengambil kata sandi dari file log.

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

Keluaran:

2021-11-27T08:27:27.063799Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: PJyCjhTjP1:n

Server MySQL aman

Sekarang, Anda perlu menjalankan mysql_secure_installation untuk mengamankan instalasi MySQL Anda. Perintah ini menangani pengaturan kata sandi root, menghapus pengguna anonim, melarang login root dari jarak jauh, dll.

mysql_secure_installation

Keluaran:

Securing the MySQL server deployment.

Enter password for user root:  << Enter the initital MySQL root password

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

New password:  << Enter new MySQL root password

Re-enter new password:  << Re-enter new MySQL 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 as we have already set new password

 ... 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  << Type Y to remove anonymous users
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  << Type Y to disallow root login remotely
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  << Type Y to remove test database
 - 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  << Type Y to reload privilege tables
Success.

All done!

Bekerja dengan Server MySQL

Masuk ke server MySQL dengan pengguna root dan kata sandinya.

mysql -u root -p

Keluaran:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.27 MySQL Community Server - GPL

Copyright (c) 2000, 2021, 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>

Instal phpMyAdmin

phpMyAdmin adalah alat manajemen berbasis web sumber terbuka untuk mengelola database MySQL dan MariaDB. Ikuti tautan di bawah ini untuk menginstal dan mengkonfigurasi phpMyAdmin berdasarkan sistem operasi Anda.

BACA:Instal phpMyAdmin di CentOS 7 / RHEL 7

Kesimpulan

Itu saja. Saya harap Anda telah mempelajari cara menginstal MySQL 8.0/5.7 di CentOS 7 / RHEL 7.


Cent OS
  1. Nonaktifkan SELinux pada CentOS atau RHEL 5/5.1/5.2/5.3/5.4/5.5/5.6/5.7

  2. Cara Menginstal MySQL 8.0 di CentOS/RHEL 8

  3. Bagaimana Cara Menginstal MySQL di CentOS 7.x?

  1. Cara Instal MySQL di CentOS 7

  2. Cara Install Apache, MySQL, PHP (LAMP) di CentOS/RHEL 7

  3. Cara Menginstal MySQL 5.6 di CentOS 6.x

  1. Cara Menginstal MySQL di CentOS 8

  2. Cara menginstal phpMyAdmin di RHEL 8 / CentOS 8

  3. Cara Menginstal P7Zip di RHEL 8 / CentOS 8