ວິທີການຕິດຕັ້ງ MySQL 8.0 ໃນ RHEL/CentOS 8/7 ແລະ Fedora 30


MySQL ແມ່ນລະບົບການຄຸ້ມຄອງຖານຂໍ້ມູນທີ່ພົວພັນແບບເປີດເສລີ (RDBMS) ທີ່ປ່ອຍອອກມາພາຍໃຕ້ GNU (General Public License). ມັນໄດ້ຖືກນໍາໃຊ້ເພື່ອດໍາເນີນການຖານຂໍ້ມູນຫຼາຍໃນເຄື່ອງແມ່ຂ່າຍດຽວໂດຍໃຫ້ການເຂົ້າເຖິງຜູ້ໃຊ້ຫຼາຍຄົນໃນແຕ່ລະຖານຂໍ້ມູນທີ່ຖືກສ້າງຂື້ນ.

ບົດຂຽນນີ້ຈະຍ່າງຜ່ານຂັ້ນຕອນການຕິດຕັ້ງແລະອັບເດດ MySQL 8.0 ລຸ້ນ ໃໝ່ ຫຼ້າສຸດໃນ RHEL/CentOS 8/7/6/ແລະ Fedora 28-30 ໂດຍໃຊ້ MySQL Yum repository ຜ່ານ YUM utility.

ຂັ້ນຕອນທີ 1: ເພີ່ມຖານຂໍ້ມູນ MySQL Yum

1. ພວກເຮົາຈະ ນຳ ໃຊ້ຫ້ອງການຊອບແວ MySQL Yum ຢ່າງເປັນທາງການ, ເຊິ່ງຈະສະ ໜອງ ຊຸດ RPM ສຳ ລັບຕິດຕັ້ງ MySQL ລຸ້ນ ໃໝ່, ລູກຄ້າ, MySQL Utilities, MySQL Workbench, Connector/ODBC, ແລະ Connector/Python ສຳ ລັບ RHEL/CentOS 8/7/6/ແລະ Fedora 28-30.

ສິ່ງ ສຳ ຄັນ: ຄຳ ແນະ ນຳ ເຫຼົ່ານີ້ເຮັດວຽກພຽງແຕ່ການຕິດຕັ້ງ MySQL ສົດໃນເຊີຟເວີເທົ່ານັ້ນ, ຖ້າມີ MySQL ຕິດຕັ້ງແລ້ວໂດຍໃຊ້ຊຸດ RPM ທີ່ແຈກຢາຍໂດຍບຸກຄົນທີສາມ, ຫຼັງຈາກນັ້ນຂ້ອຍແນະ ນຳ ໃຫ້ທ່ານຍົກລະດັບຫຼືປ່ຽນຊຸດ MySQL ທີ່ຕິດຕັ້ງໂດຍໃຊ້ MySQL Yum Repository ”.

ກ່ອນທີ່ຈະຍົກລະດັບຫຼືປ່ຽນແທນຊຸດ MySQL ເກົ່າ, ຢ່າລືມທີ່ຈະເອົາ ສຳ ຮອງແລະເອກະສານການຕັ້ງຄ່າຖານຂໍ້ມູນທີ່ ສຳ ຄັນໄວ້.

2. ດຽວນີ້ດາວໂລດແລະເພີ່ມບ່ອນເກັບ MySQL Yum ຕໍ່ໄປນີ້ເຂົ້າໃນບັນຊີລາຍຊື່ຂອງລະບົບການແຈກຈ່າຍ Linux ທີ່ກ່ຽວຂ້ອງຂອງທ່ານເພື່ອຕິດຕັ້ງ MySQL ເວີຊັ່ນລ້າສຸດ (i. 8.0 ທີ່ປ່ອຍອອກມາໃນວັນທີ 27 ກໍລະກົດ 2018).

--------------- On RHEL/CentOS 8 ---------------
# wget https://repo.mysql.com/mysql80-community-release-el8-1.noarch.rpm
--------------- On RHEL/CentOS 7 ---------------
# wget https://repo.mysql.com/mysql80-community-release-el7-1.noarch.rpm
--------------- On RHEL/CentOS 6 ---------------
# wget https://dev.mysql.com/get/mysql80-community-release-el6-1.noarch.rpm
--------------- On Fedora 30 ---------------
# wget https://dev.mysql.com/get/mysql80-community-release-fc30-1.noarch.rpm
--------------- On Fedora 29 ---------------
# wget https://dev.mysql.com/get/mysql80-community-release-fc29-1.noarch.rpm
--------------- On Fedora 28 ---------------
# wget https://dev.mysql.com/get/mysql80-community-release-fc28-1.noarch.rpm

3. ຫຼັງຈາກດາວໂຫລດແພັກເກດ ສຳ ລັບແພລະຕະຟອມ Linux ຂອງທ່ານ, ດຽວນີ້ຕິດຕັ້ງຊຸດທີ່ດາວໂຫລດມາພ້ອມດ້ວຍ ຄຳ ສັ່ງຕໍ່ໄປນີ້.

--------------- On RHEL/CentOS 8 ---------------
# yum localinstall mysql80-community-release-el8-1.noarch.rpm
--------------- On RHEL/CentOS 7 ---------------
# yum localinstall mysql80-community-release-el7-1.noarch.rpm
--------------- On RHEL/CentOS 6 ---------------
# yum localinstall mysql80-community-release-el6-1.noarch.rpm
--------------- On Fedora 30 ---------------
# dnf localinstall mysql80-community-release-fc30-1.noarch.rpm
--------------- On Fedora 29 ---------------
# dnf localinstall mysql80-community-release-fc29-1.noarch.rpm
--------------- On Fedora 28 ---------------
# yum localinstall mysql80-community-release-fc28-1.noarch.rpm

ຄຳ ສັ່ງໃນການຕິດຕັ້ງຂ້າງເທິງຈະເພີ່ມຖານຂໍ້ມູນ MySQL Yum ເຂົ້າໃນບັນຊີລາຍຊື່ຫໍສະມຸດຂອງລະບົບແລະດາວໂຫລດປຸ່ມ GnuPG ເພື່ອກວດສອບຄວາມຖືກຕ້ອງຂອງແພັກເກດ.

4. ທ່ານສາມາດກວດສອບໄດ້ວ່າຖານຂໍ້ມູນ MySQL Yum ໄດ້ຖືກເພີ່ມເຂົ້າໄປຢ່າງ ສຳ ເລັດຜົນໂດຍໃຊ້ ຄຳ ສັ່ງຕໍ່ໄປນີ້.

# yum repolist enabled | grep "mysql.*-community.*"
# dnf repolist enabled | grep "mysql.*-community.*"      [On Fedora versions]

ຂັ້ນຕອນທີ 2: ການຕິດຕັ້ງ MySQL ລຸ້ນລ້າສຸດ

5. ຕິດຕັ້ງ MySQL ລຸ້ນລ້າສຸດ (ປະຈຸບັນ 8.0) ໂດຍໃຊ້ ຄຳ ສັ່ງຕໍ່ໄປນີ້.

# yum install mysql-community-server
# dnf install mysql-community-server      [On Fedora versions]

ຄຳ ສັ່ງຂ້າງເທິງຕິດຕັ້ງທຸກຊຸດທີ່ ຈຳ ເປັນ ສຳ ລັບ MySQL server mysql-community-server, mysql-community-client, mysql-community-common ແລະ mysql-community-libs.

ຂັ້ນຕອນທີ 3: ການຕິດຕັ້ງຊຸດການປ່ອຍ MySQL

6. ທ່ານຍັງສາມາດຕິດຕັ້ງ MySQL ເວີຊັນທີ່ແຕກຕ່າງກັນໂດຍໃຊ້ຫໍສະ ໝຸດ ຍ່ອຍຂອງ MySQL Community Server. ຫໍສະ ໝຸດ ຍ່ອຍ ສຳ ລັບຊຸດ MySQL ທີ່ຜ່ານມາ (ປະຈຸບັນ MySQL 8.0) ຖືກເປີດໃຊ້ໂດຍຄ່າເລີ່ມຕົ້ນ, ແລະຫໍສະ ໝຸດ ຍ່ອຍ ສຳ ລັບທຸກລຸ້ນອື່ນໆ (ຕົວຢ່າງ, ຊຸດ MySQL 5.x) ຖືກປິດໃຊ້ງານໂດຍຄ່າເລີ່ມຕົ້ນ.

ເພື່ອຕິດຕັ້ງເວີຊັນສະເພາະຈາກບ່ອນຈັດເກັບຍ່ອຍສະເພາະ, ທ່ານສາມາດໃຊ້ຕົວເລືອກ - ເປີດໃຊ້ໄດ້ຫລືລະຫັດ - ເປີດໃຊ້ໄດ້ ໂດຍໃຊ້ yum-config-manager ຫຼື dnf config-manager ດັ່ງທີ່ສະແດງ:

# yum-config-manager --disable mysql57-community
# yum-config-manager --enable mysql56-community
------------------ Fedora Versions ------------------
# dnf config-manager --disable mysql57-community
# dnf config-manager --enable mysql56-community

ຂັ້ນຕອນທີ 4: ເລີ່ມຕົ້ນ MySQL Server

7. ຫຼັງຈາກການຕິດຕັ້ງ MySQL ສຳ ເລັດແລ້ວ, ມັນແມ່ນເວລາທີ່ຈະເລີ່ມຕົ້ນ MySQL server ດ້ວຍ ຄຳ ສັ່ງດັ່ງຕໍ່ໄປນີ້:

# service mysqld start

ທ່ານສາມາດກວດສອບສະຖານະຂອງເຊີຟເວີ MySQL ໂດຍການຊ່ວຍເຫຼືອຂອງ ຄຳ ສັ່ງຕໍ່ໄປນີ້.

# service mysqld status

ນີ້ແມ່ນຜົນໄດ້ຮັບຕົວຢ່າງຂອງການເຮັດວຽກ MySQL ພາຍໃຕ້ກ່ອງ CentOS 7 ຂອງຂ້ອຍ.

Redirecting to /bin/systemctl status  mysqld.service
mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled)
   Active: active (running) since Thu 2015-10-29 05:15:19 EDT; 4min 5s ago
  Process: 5314 ExecStart=/usr/sbin/mysqld --daemonize $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
  Process: 5298 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 5317 (mysqld)
   CGroup: /system.slice/mysqld.service
           └─5317 /usr/sbin/mysqld --daemonize

Oct 29 05:15:19 localhost.localdomain systemd[1]: Started MySQL Server.

8. ຕອນນີ້ກວດສອບເວີຊັນ MySQL ທີ່ຕິດຕັ້ງແລ້ວໂດຍໃຊ້ ຄຳ ສັ່ງຕໍ່ໄປນີ້.

# mysql --version

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

ຂັ້ນຕອນທີ 5: ຮັບປະກັນການຕິດຕັ້ງ MySQL

9. ຄຳ ສັ່ງ mysql_secure_installation ຊ່ວຍໃຫ້ທ່ານສາມາດຮັບປະກັນການຕິດຕັ້ງ MySQL ຂອງທ່ານໂດຍປະຕິບັດການຕັ້ງຄ່າທີ່ ສຳ ຄັນເຊັ່ນການຕັ້ງລະຫັດລັບ, ກຳ ຈັດຜູ້ໃຊ້ທີ່ບໍ່ລະບຸຊື່, ກຳ ຈັດການເຂົ້າສູ່ລະບົບຮາກ, ແລະອື່ນໆ.

ໝາຍ ເຫດ: MySQL ລຸ້ນ 8.0 ຫຼືສູງກວ່າຈະສ້າງລະຫັດລັບແບບສຸ່ມໃນຊົ່ວຄາວໃນ /var/log/mysqld.log ຫຼັງຈາກຕິດຕັ້ງແລ້ວ.

ໃຊ້ ຄຳ ສັ່ງຂ້າງລຸ່ມນີ້ເພື່ອເບິ່ງລະຫັດຜ່ານກ່ອນທີ່ຈະໃຊ້ ຄຳ ສັ່ງທີ່ປອດໄພຂອງ MySQL.

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

ເມື່ອທ່ານຮູ້ລະຫັດຜ່ານແລ້ວຕອນນີ້ທ່ານສາມາດ ດຳ ເນີນການ ຄຳ ສັ່ງຕໍ່ໄປນີ້ເພື່ອຮັບປະກັນການຕິດຕັ້ງ MySQL ຂອງທ່ານ.

# mysql_secure_installation

ໝາຍ ເຫດ: ໃສ່ລະຫັດລັບ Root ໃໝ່ ໝາຍ ເຖິງລະຫັດລັບຊົ່ວຄາວຂອງທ່ານຈາກແຟ້ມ /var/log/mysqld.log .

ຕອນນີ້ໃຫ້ເຮັດຕາມ ຄຳ ແນະ ນຳ ເທິງ ໜ້າ ຈໍຢ່າງລະມັດລະວັງ, ສຳ ລັບການອ້າງອີງເບິ່ງຜົນໄດ້ຮັບຂອງ ຄຳ ສັ່ງຂ້າງເທິງຂ້າງລຸ່ມນີ້.

Securing the MySQL server deployment.

Enter password for user root: Enter New Root Password

VALIDATE PASSWORD PLUGIN 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 plugin?

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: 2
Using existing password for root.

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

New password: Set New MySQL Password

Re-enter new password: Re-enter New MySQL 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! 

ຂັ້ນຕອນທີ 6: ການເຊື່ອມຕໍ່ກັບ MySQL Server

10. ເຊື່ອມຕໍ່ກັບເຊີບເວີ MySQL ທີ່ຕິດຕັ້ງ ໃໝ່ ໂດຍການໃຫ້ຊື່ຜູ້ໃຊ້ແລະລະຫັດຜ່ານ.

# mysql -u root -p
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 19
Server version: 8.0.1 MySQL Community Server (GPL)

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

ຂັ້ນຕອນທີ 7: ອັບເດດ MySQL ກັບ Yum

11. ນອກຈາກການຕິດຕັ້ງສົດ, ທ່ານຍັງສາມາດເຮັດການອັບເດດ ສຳ ລັບຜະລິດຕະພັນແລະສ່ວນປະກອບ MySQL ໂດຍການຊ່ວຍເຫຼືອຂອງ ຄຳ ສັ່ງຕໍ່ໄປນີ້.

# yum update mysql-server
# dnf update mysql-server       [On Fedora versions]

ເມື່ອມີການປັບປຸງ ໃໝ່ ສຳ ລັບ MySQL, ມັນຈະຕິດຕັ້ງພວກມັນໂດຍອັດຕະໂນມັດ, ຖ້າບໍ່ແມ່ນທ່ານຈະໄດ້ຮັບຂໍ້ຄວາມທີ່ກ່າວວ່າບໍ່ມີແພັກເກດ ໝາຍ ສຳ ລັບການອັບເດດ.

ນັ້ນແມ່ນມັນ, ທ່ານໄດ້ຕິດຕັ້ງ MySQL 8.0 ສຳ ເລັດໃນລະບົບຂອງທ່ານແລ້ວ. ຖ້າທ່ານມີບັນຫາໃນການຕິດຕັ້ງຮູ້ສຶກບໍ່ເສຍຄ່າໃຊ້ພາກ ຄຳ ເຫັນຂອງພວກເຮົາເພື່ອແກ້ໄຂບັນຫາ.