Kā instalēt MySQL 8.0 RHEL/CentOS 8/7 un Fedora 30


MySQL ir atvērtā koda bezmaksas relāciju datu bāzes pārvaldības sistēma (RDBMS), kas izlaista ar GNU (General Public License). To izmanto, lai palaistu vairākas datu bāzes jebkurā serverī, nodrošinot vairāku lietotāju piekļuvi katrai izveidotajai datu bāzei.

Šajā rakstā būs aprakstīts jaunākās MySQL 8.0 versijas instalēšanas un atjaunināšanas process RHEL/CentOS 8/7/6/un Fedora 28-30, izmantojot MySQL Yum repozitoriju, izmantojot YUM utilītu.

1. darbība: MySQL Yum krātuves pievienošana

1. Mēs izmantosim oficiālo MySQL Yum programmatūras repozitoriju, kas nodrošinās RPM paketes, lai instalētu jaunāko MySQL servera versiju, klientu, MySQL Utilities, MySQL Workbench, Connector/ODBC un Connector/Python RHEL/CentOS 8/7/6/un Fedora 28.-30.

Svarīgi: Šie norādījumi darbojas tikai ar jaunu MySQL instalēšanu serverī, ja jau ir instalēta MySQL, izmantojot trešo pušu izplatītu RPM pakotni, tad iesaku atjaunināt vai nomainīt instalēto MySQL pakotni, izmantojot MySQL Yum repozitoriju. ”.

Pirms vecās MySQL pakotnes jaunināšanas vai nomaiņas neaizmirstiet paņemt visus svarīgos datu bāzes dublējuma un konfigurācijas failus.

2. Tagad lejupielādējiet un pievienojiet šo MySQL Yum repozitoriju attiecīgās Linux izplatīšanas sistēmas krātuvju sarakstam, lai instalētu jaunāko MySQL versiju (t.i., 8.0, kas izlaista 2018. gada 27. jūlijā).

--------------- 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. Pēc pakotnes lejupielādes Linux platformai tagad instalējiet lejupielādēto pakotni ar šādu komandu.

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

Iepriekš minētā instalēšanas komanda pievieno MySQL Yum repozitoriju sistēmas krātuvju sarakstam un lejupielādē GnuPG atslēgu, lai pārbaudītu pakotņu integritāti.

4. Varat pārbaudīt, vai MySQL Yum krātuve ir veiksmīgi pievienota, izmantojot šādu komandu.

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

2. solis: Jaunākās MySQL versijas instalēšana

5. Instalējiet jaunāko MySQL versiju (pašlaik 8.0), izmantojot šādu komandu.

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

Iepriekš minētā komanda instalē visas nepieciešamās pakotnes MySQL serverim mysql-community-server, mysql-community-client, mysql-community-common un mysql-community-libs.

3. solis: MySQL laidienu sērijas instalēšana

6. Varat arī instalēt dažādas MySQL versijas, izmantojot dažādus MySQL Kopienas servera apakškrātuves. Nesenās MySQL sērijas (šobrīd MySQL 8.0) apakškrātuve tiek aktivizēta pēc noklusējuma, un visu pārējo versiju (piemēram, MySQL 5.x sērijas) apakškrātuves pēc noklusējuma tiek deaktivizētas.

Lai instalētu konkrētu versiju no konkrēta apakšrepozitorija, varat izmantot opcijas --enable vai --disable , izmantojot yum-config-manager vai dnf config-manager, kā parādīts:

# 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. darbība: MySQL servera palaišana

7. Pēc veiksmīgas MySQL instalēšanas ir pienācis laiks sākt MySQL serveri ar šādu komandu:

# service mysqld start

MySQL servera statusu var pārbaudīt ar šīs komandas palīdzību.

# service mysqld status

Šis ir MySQL palaišanas paraugs manā lodziņā 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. Tagad beidzot pārbaudiet instalēto MySQL versiju, izmantojot šādu komandu.

# mysql --version

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

5. darbība: MySQL instalācijas drošība

9. Komanda mysql_secure_installation ļauj jums nodrošināt MySQL instalēšanu, veicot svarīgus iestatījumus, piemēram, iestatot saknes paroli, noņemot anonīmus lietotājus, noņemot root pieteikšanos utt.

Piezīme: MySQL 8.0 vai jaunāka versija ģenerē pagaidu nejaušu paroli mapē /var/log/mysqld.log pēc instalēšanas.

Pirms palaižat MySQL drošu komandu, izmantojiet zemāk esošo komandu, lai redzētu paroli.

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

Kad esat zinājis paroli, tagad varat izpildīt komandu, lai nodrošinātu MySQL instalēšanu.

# mysql_secure_installation

Piezīme. Ievadiet jaunu saknes paroli, kas nozīmē jūsu pagaidu paroli no faila /var/log/mysqld.log .

Tagad uzmanīgi izpildiet ekrānā redzamos norādījumus, lai uzzinātu, skatiet iepriekš minētās komandas izvadi.

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. darbība: savienojuma izveide ar MySQL serveri

10. Savienojuma izveide ar tikko instalētu MySQL serveri, norādot lietotājvārdu un paroli.

# 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. darbība: MySQL atjaunināšana ar Yum

11. Papildus jaunai instalēšanai jūs varat arī atjaunināt MySQL produktus un komponentus, izmantojot šo komandu.

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

Kad MySQL būs pieejami jauni atjauninājumi, tā tos automātiski instalēs, ja nē, jūs saņemsit ziņojumu, kurā teikts, ka atjauninājumiem nav atzīmētas NO paketes.

Tas ir viss, jūs esat veiksmīgi instalējis MySQL 8.0 savā sistēmā. Ja rodas problēmas ar instalēšanu, risinājumiem izmantojiet mūsu komentāru sadaļu.