Kaip įdiegti „MySQL 8.0“ „RHEL/CentOS 8/7“ ir „Fedora 35“


MySQL yra atvirojo kodo nemokama reliacinė duomenų bazių valdymo sistema (RDBMS), išleista pagal GNU (bendra viešoji licencija). . Jis naudojamas kelioms duomenų bazėms paleisti viename serveryje, suteikiant kelių vartotojų prieigą prie kiekvienos sukurtos duomenų bazės.

Šiame straipsnyje bus paaiškinta, kaip įdiegti ir atnaujinti naujausią MySQL 8.0 versiją RHEL/CentOS 8/7/6/ ir Fedora naudojant MySQL Yum saugyklą per YUM priemonę.

1 veiksmas: pridėkite „MySQL Yum“ saugyklą

1. Naudosime oficialią MySQL Yum programinės įrangos saugyklą, kuri pateiks RPM paketus, skirtus įdiegti naujausią MySQL serverio, kliento, MySQL paslaugų, MySQL Workbench, Connector/ versiją. ODBC ir jungtis/Python, skirta RHEL/CentOS 8/7/6/ ir Fedora 30–35.

Svarbu: šios instrukcijos veikia tik iš naujo įdiegus MySQL serveryje, jei jau yra MySQL > įdiegta naudojant trečiosios šalies platinamą RPM paketą, tada rekomenduoju atnaujinti arba pakeisti įdiegtą MySQL paketą naudojant MySQL Yum saugyklą “.

Prieš atnaujindami arba keisdami seną MySQL paketą, nepamirškite pasidaryti visų svarbių duomenų bazės atsarginių kopijų ir konfigūracijos failų, naudodami mūsų atsarginių MySQL duomenų bazių vadovą.

2. Dabar atsisiųskite ir pridėkite šią MySQL Yum saugyklą prie atitinkamos Linux platinimo sistemos saugyklos sąrašo, kad įdiegtumėte naujausią MySQL versiją (t. y. 8.0). išleista 2018 m. liepos 27 d.).

--------------- 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 35 ---------------
wget https://dev.mysql.com/get/mysql80-community-release-fc35-1.noarch.rpm
--------------- On Fedora 34 ---------------
wget https://dev.mysql.com/get/mysql80-community-release-fc34-1.noarch.rpm
--------------- On Fedora 33 ---------------
wget https://dev.mysql.com/get/mysql80-community-release-fc33-1.noarch.rpm

3. Atsisiuntę paketą savo Linux platformai, dabar įdiekite atsisiųstą paketą naudodami šią komandą.

--------------- 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 35 ---------------
dnf localinstall mysql80-community-release-fc35-1.noarch.rpm
--------------- On Fedora 34 ---------------
dnf localinstall mysql80-community-release-fc34-1.noarch.rpm
--------------- On Fedora 33 ---------------
yum localinstall mysql80-community-release-fc33-1.noarch.rpm

Aukščiau pateikta diegimo komanda prideda MySQL Yum saugyklą prie sistemos saugyklų sąrašo ir atsisiunčia GnuPG raktą, kad patikrintų paketų vientisumą.

4. Galite patikrinti, ar „MySQL Yum“ saugykla buvo sėkmingai pridėta, naudodami šią komandą.

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

2 veiksmas: įdiekite naujausią „MySQL“ versiją

5. Įdiekite naujausią MySQL versiją (šiuo metu 8.0) naudodami šią komandą.

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

Aukščiau pateikta komanda įdiegia visus reikalingus paketus MySQL serveriui mysql-community-server, mysql-community-client, mysql-community-common ir mysql-community-libs.

3 veiksmas: skirtingų MySQL leidimo versijų diegimas

6. Taip pat galite įdiegti skirtingas MySQL versijas naudodami skirtingas MySQL bendruomenės serverio antrines saugyklas. Naujausios MySQL serijos (šiuo metu MySQL 8.0) antrinė saugykla yra suaktyvinta pagal numatytuosius nustatymus, o visų kitų versijų (pvz., MySQL 5.x serijos) antrinės saugyklos yra išjungtos pagal numatytuosius nustatymus. .

Norėdami įdiegti konkrečią versiją iš konkrečios antrinės saugyklos, galite naudoti parinktis --enable arba --disable naudodami yum-config-manager arba dnf config-manager, kaip parodyta:

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 veiksmas: paleiskite „MySQL Server“.

7. Sėkmingai įdiegus MySQL, laikas paleisti ir įgalinti MySQL serverį šiomis komandomis:

service mysqld start
systemctl enable mysqld.service

MySQL serverio būseną galite patikrinti naudodami šią komandą.

systemctl status mysqld.service
OR
service mysqld status

Tai yra „MySQL“ paleidimo mano CentOS 7 langelyje pavyzdys.

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. Dabar pagaliau patikrinkite įdiegtą MySQL versiją naudodami šią komandą.

mysql --version

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

5 veiksmas: MySQL diegimo apsauga

9. Komanda mysql_secure_installation leidžia apsaugoti MySQL diegimą atliekant svarbius nustatymus, pvz., nustatant pagrindinį slaptažodį, pašalinant anoniminius vartotojus, pašalinant root prisijungimą ir pan.

Pastaba: „MySQL“ versija 8.0 arba naujesnė versija sugeneruoja laikiną atsitiktinį slaptažodį /var/log/mysqld.log po įdiegimo.

Naudokite toliau pateiktą komandą, kad pamatytumėte slaptažodį prieš paleisdami MySQL saugią komandą.

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

Kai žinosite slaptažodį, dabar galite paleisti šią komandą, kad apsaugotumėte savo MySQL diegimą.

mysql_secure_installation

Pastaba: Įveskite naują pagrindinį slaptažodį reiškia laikiną slaptažodį iš failo /var/log/mysqld.log.

Dabar atidžiai vykdykite ekrane pateikiamas instrukcijas, žr. toliau pateiktos komandos išvestį.

Pavyzdžio išvestis
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 veiksmas: prisijunkite prie „MySQL Server“.

10. Prisijunkite prie naujai įdiegto MySQL serverio pateikdami naudotojo vardą ir slaptažodį.

mysql -u root -p

Išvesties pavyzdys:

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>

7 veiksmas: MySQL atnaujinimas naudojant Yum

11. Be naujo diegimo, taip pat galite atnaujinti MySQL produktus ir komponentus naudodami šią komandą.

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

Kai bus pasiekiami nauji MySQL naujinimai, jie bus automatiškai įdiegti, o jei ne, gausite pranešimą NĖRA pažymėtų naujinimams paketų.

Viskas, sėkmingai įdiegėte MySQL 8.0 savo sistemoje. Jei kyla problemų diegiant, nedvejodami naudokite mūsų komentarų skiltį.