Hvernig á að setja upp MySQL 8.0 á RHEL/CentOS 8/7 og Fedora 35


MySQL er opinn uppspretta ókeypis samskiptagagnagrunnsstjórnunarkerfi (RDBMS) gefið út undir GNU (General Public License). Það er notað til að keyra marga gagnagrunna á hverjum einum netþjóni með því að veita fjölnotendaaðgang að hverjum stofnuðum gagnagrunni.

Þessi grein mun ganga í gegnum þig ferlið við að setja upp og uppfæra nýjustu MySQL 8.0 útgáfuna á RHEL/CentOS 8/7/6/ og Fedora með því að nota MySQL Yum geymslu í gegnum YUM gagnsemi.

Skref 1: Bæta við MySQL Yum geymslunni

1. Við munum nota opinberu MySQL Yum hugbúnaðargeymsluna, sem mun veita RPM pakka til að setja upp nýjustu útgáfuna af MySQL netþjóni, biðlara, MySQL tólum, MySQL vinnubekk, tengi/ODBC og tengi/Python fyrir RHEL/CentOS 8/7 /6/ og Fedora 30-35.

Mikilvægt: Þessar leiðbeiningar virka aðeins á nýrri uppsetningu á MySQL á þjóninum, ef það er þegar MySQL uppsett með því að nota þriðja aðila-dreifðan RPM pakka, þá mæli ég með að þú uppfærir eða skipta um uppsetta MySQL pakkann með MySQL Yum Repository “.

Áður en þú uppfærir eða skiptir út gömlum MySQL pakka skaltu ekki gleyma að taka allar mikilvægar öryggisafrit og stillingarskrár gagnagrunns með því að nota Backup MySQL gagnagrunnahandbókina okkar.

2. Hladdu nú niður og bættu eftirfarandi MySQL Yum geymslu við geymslulista viðkomandi Linux dreifikerfis til að setja upp nýjustu útgáfuna af MySQL (þ.e. 8.0 gefin út 27. júlí 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 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. Eftir að hafa hlaðið niður pakkanum fyrir Linux pallinn þinn, settu nú niður pakkann með eftirfarandi skipun.

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

Ofangreind uppsetningarskipun bætir MySQL Yum geymslunni við geymslulista kerfisins og hleður niður GnuPG lyklinum til að staðfesta heilleika pakkana.

4. Þú getur staðfest að MySQL Yum geymslunni hafi verið bætt við með góðum árangri með því að nota eftirfarandi skipun.

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

Skref 2: Setja upp nýjustu MySQL útgáfuna

5. Settu upp nýjustu útgáfuna af MySQL (nú 8.0) með því að nota eftirfarandi skipun.

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

Ofangreind skipun setur upp alla nauðsynlega pakka fyrir MySQL miðlara mysql-community-server, mysql-community-client, mysql-community-common og mysql-community-libs.

Skref 3: Að setja upp mismunandi MySQL útgáfur

6. Þú getur líka sett upp mismunandi MySQL útgáfur með því að nota mismunandi undirgeymslur MySQL Community Server. Undirgeymslan fyrir nýjustu MySQL seríurnar (nú MySQL 8.0) er sjálfgefið virkjuð og undirgeymslan fyrir allar aðrar útgáfur (til dæmis MySQL 5.x seríurnar) eru sjálfgefið óvirkar.

Til að setja upp ákveðna útgáfu úr tiltekinni undirgeymslu geturðu notað valkostina --enable eða --disable með því að nota yum-config-manager eða dnf config-manager eins og sýnt er. :

# 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

Skref 4: Ræsa MySQL Server

7. Eftir vel heppnaða uppsetningu á MySQL er kominn tími til að ræsa og virkja MySQL þjóninn með eftirfarandi skipunum:

# service mysqld start
# systemctl enable mysqld.service

Þú getur staðfest stöðu MySQL netþjónsins með hjálp eftirfarandi skipunar.

# systemctl status mysqld.service
OR
# service mysqld status

Þetta er sýnishornið af því að keyra MySQL undir CentOS 7 kassanum mínum.

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. Staðfestu nú loksins uppsettu MySQL útgáfuna með því að nota eftirfarandi skipun.

# mysql --version

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

Skref 5: Að tryggja MySQL uppsetninguna

9. Skipunin mysql_secure_installation gerir þér kleift að tryggja MySQL uppsetninguna þína með því að framkvæma mikilvægar stillingar eins og að setja rót lykilorðið, fjarlægja nafnlausa notendur, fjarlægja rót innskráningu, og svo framvegis.

Athugið: MySQL útgáfa 8.0 eða nýrri býr til tímabundið handahófskennt lykilorð í /var/log/mysqld.log eftir uppsetningu.

Notaðu skipunina hér að neðan til að sjá lykilorðið áður en þú keyrir MySQL örugga skipun.

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

Þegar þú veist lykilorðið geturðu keyrt eftirfarandi skipun til að tryggja MySQL uppsetninguna þína.

# mysql_secure_installation

Athugið: Sláðu inn nýtt rótarlykilorð þýðir tímabundið lykilorð þitt úr skránni /var/log/mysqld.log.

Fylgdu nú leiðbeiningunum á skjánum vandlega, til viðmiðunar sjáðu úttak ofangreindrar skipunar hér að neðan.

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! 

Skref 6: Tengist MySQL Server

10. Tengstu við nýuppsettan MySQL netþjón með því að gefa upp notandanafn og lykilorð.

# mysql -u root -p
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>

Skref 7: Uppfærsla MySQL með Yum

11. Fyrir utan nýja uppsetningu geturðu einnig gert uppfærslur fyrir MySQL vörur og íhluti með hjálp eftirfarandi skipunar.

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

Þegar nýjar uppfærslur eru fáanlegar fyrir MySQL mun það setja þær upp sjálfkrafa, ef ekki færðu skilaboð sem segja ENGIR pakkar merktir fyrir uppfærslur.

Það er það, þú hefur sett upp MySQL 8.0 á vélinni þinni. Ef þú átt í vandræðum með að setja upp skaltu ekki hika við að nota athugasemdareitinn okkar til að fá lausnir.