GNU/Linux >> Belajar Linux >  >> Linux

Cara Menginstal MySQL 5.7 di Amazon Linux

MySQL adalah sistem basis data relasional. Dalam tutorial kami sebelumnya, Anda menginstal Apache dan PHP di Amazon Linux. Tutorial ini akan membantu Anda menginstal MySQL 5.7 di sistem Amazon Linux.

Prasyarat

Masuk ke sistem Fedora Anda dan buka terminal. Sekarang tingkatkan paket saat ini ke versi terbaru dengan menjalankan perintah berikut.

sudo yum update -y 

Langkah 1 – Instal MySQL di Amazon Linux

Repositori default Amazon Linux berisi paket Mariadb untuk penginstalan. Untuk menginstal rilis komunitas MySQL, pertama-tama konfigurasikan repositori MySQL yum di komputer Anda.

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

Setelah itu jalankan perintah berikut untuk menginstal paket MySQL 5.7 di sistem Anda. Ini juga akan menginstal semua dependensi lain yang diperlukan.

sudo yum install mysql-community-server 
Dependencies Resolved                                                                                 

============================================================================================================
 Package                             Arch           Version                     Repository             Size
============================================================================================================
Installing:                                                                                           
 mysql-community-libs                x86_64         5.7.32-1.el7                mysql57-community     2.3 M
     replacing  mariadb-libs.x86_64 1:5.5.68-1.amzn2                                                  
 mysql-community-libs-compat         x86_64         5.7.32-1.el7                mysql57-community     1.2 M
     replacing  mariadb-libs.x86_64 1:5.5.68-1.amzn2                                                  
 mysql-community-server              x86_64         5.7.32-1.el7                mysql57-community     173 M
Installing for dependencies:                                                                          
 mysql-community-client              x86_64         5.7.32-1.el7                mysql57-community      25 M
 mysql-community-common              x86_64         5.7.32-1.el7                mysql57-community     308 k
 ncurses-compat-libs                 x86_64         6.0-8.20170212.amzn2.1.3    amzn2-core            308 k

Transaction Summary                                                                                   
============================================================================================================
Install  3 Packages (+3 Dependent packages)                                                           

Total download size: 203 M                                                                            
Is this ok [y/d/N]: y

Tekan 'y' saat diminta konfirmasi untuk menyelesaikan instalasi.

Setelah instalasi MySQL selesai di sistem Amazon Linux Anda. Anda harus mengaktifkan layanan MySQL untuk memulai pada boot sistem. Juga, mulai layanan menggunakan perintah berikut:

sudo systemctl enable mysqld 
sudo systemctl start mysqld 

Setelah Anda memulai server MySQL untuk pertama kalinya, kata sandi yang dibuat secara otomatis diatur untuk akun root. Anda dapat menemukan kata sandi ini di log MySQL.

sudo grep 'temporary password' /var/log/mysqld.log 

2020-10-31T06:37:32.258128Z 1 [Note] A temporary password is generated for [email protected]: /c5>WMwMHmaV

Salin sandi ini dan gunakan ini untuk wizard penyiapan pasca-penginstalan.

Langkah 2 – Setelah Pemasangan Pemasangan

Server komunitas MySQL telah diinstal pada sistem Anda. Sekarang jalankan perintah berikut untuk menerapkan keamanan pada server MySQL. Cukup jalankan perintah di bawah ini dan ikuti wizard keamanan.

sudo mysql_secure_installation 

Masukkan kata sandi root yang ditemukan pada langkah di atas, lalu atur kata sandi baru untuk akun root mysql. Selanjutnya, ikuti petunjuk di layar dan Tekan Y untuk semua operasi lain guna menerapkan keamanan yang ditingkatkan.

Securing the MySQL server deployment.

Enter password for user root:

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

New password:

Re-enter new password:
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) : n

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

Langkah 3 – Hubungkan Terminal MySQL

Semua selesai. Anda sekarang dapat terhubung ke server MySQL menggunakan baris perintah. Perintah berikut akan menghubungkan MySQL yang berjalan di localhost sebagai pengguna root. Ini akan meminta kata sandi akun root.

mysql -u root -p

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

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

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>

Kesimpulan

Dalam tutorial ini, Anda telah belajar menginstal server komunitas MySQL pada sistem Amazon Linux 2.


Linux
  1. Cara Menginstal MySQL 8.0 di Fedora 35 / Fedora 34

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

  3. Cara Instal MySQL di Linux

  1. Bagaimana menginstal Mysql 8 di Rocky Linux/Centos 8

  2. Cara Menginstal MySQL di Fedora 35

  3. Cara Menginstal MySQL di Ubuntu 18.04

  1. Cara Menginstal ImageMagick di Amazon Linux

  2. Cara Menginstal MySQL di Ubuntu 22.04

  3. Bagaimana cara menginstal Postgresql 11 di Amazon Linux AMI?