Kuinka asentaa MySQL 8.0 RHEL/CentOS 8/7: een ja Fedora 30: een
MySQL on avoimen lähdekoodin ilmainen relaatiotietokantojen hallintajärjestelmä (RDBMS), joka on julkaistu GNU: lla (General Public License). Sitä käytetään ajamaan useita tietokantoja millä tahansa yhdellä palvelimella tarjoamalla monen käyttäjän pääsy jokaiseen luotuun tietokantaan.
Tässä artikkelissa käydään läpi uusimman MySQL 8.0 -version asentaminen ja päivittäminen RHEL/CentOS 8/7/6/ja Fedora 28-30 -sovelluksiin käyttämällä MySQL Yum -tietovarastoa YUM-apuohjelman kautta.
Vaihe 1: MySQL Yum -tietovaraston lisääminen
1. Käytämme virallista MySQL Yum -ohjelmistovarastoa, joka tarjoaa RPM-paketteja MySQL-palvelimen, asiakkaan, MySQL-apuohjelmien, MySQL Workbenchin, Connector/ODBC: n ja Connector/Pythonin uusimman version asentamiseen RHEL/CentOS 8/7: lle./6/ja Fedora 28-30.
Tärkeää: Nämä ohjeet toimivat vain MySQL: n uudella asennuksella palvelimelle, jos MySQL on jo asennettu kolmannen osapuolen jakamalla RPM-paketilla, suosittelen päivittämään tai korvaamaan asennettu MySQL-paketti MySQL Yum -tietovarastolla ”.
Ennen kuin päivität tai vaihdat vanhan MySQL-paketin, muista unohtaa ottaa kaikki tärkeät tietokannan varmuuskopiointi- ja määritystiedostot.
2. Lataa ja lisää seuraava MySQL Yum -tietovarasto Linux-jakelujärjestelmän arkistoluetteloon asentaaksesi MySQL: n uusimman version (ts. 8.0 julkaistu 27. heinäkuuta 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. Kun olet ladannut paketin Linux-käyttöjärjestelmällesi, asenna nyt ladattu paketti seuraavalla komennolla.
--------------- 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
Yllä oleva asennuskomento lisää MySQL Yum -tietovaraston järjestelmän arkistoluetteloon ja lataa GnuPG-avaimen pakettien eheyden varmistamiseksi.
4. Voit varmistaa, että MySQL Yum -tietovarasto on lisätty onnistuneesti, käyttämällä seuraavaa komentoa.
# yum repolist enabled | grep "mysql.*-community.*" # dnf repolist enabled | grep "mysql.*-community.*" [On Fedora versions]
Vaihe 2: Asenna uusin MySQL-versio
5. Asenna MySQL: n uusin versio (tällä hetkellä 8.0) seuraavalla komennolla.
# yum install mysql-community-server # dnf install mysql-community-server [On Fedora versions]
Yllä oleva komento asentaa kaikki tarvittavat paketit MySQL-palvelimelle mysql-community-server, mysql-community-client, mysql-community-common ja mysql-community-libs.
Vaihe 3: Asenna MySQL Release Series
6. Voit myös asentaa erilaisia MySQL-versioita käyttämällä eri MySQL-yhteisöpalvelimen alivarastoja. Viimeaikaisen MySQL-sarjan (tällä hetkellä MySQL 8.0) alivarasto on oletusarvoisesti aktivoitu, ja kaikkien muiden versioiden (esimerkiksi MySQL 5.x -sarjan) alivarastot poistetaan käytöstä oletusarvoisesti.
Voit asentaa tietyn version tietystä alivarastosta käyttämällä --enable
- tai --disable
-vaihtoehtoja yum-config-managerin tai dnf config-managerin avulla kuvan osoittamalla tavalla:
# 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
Vaihe 4: MySQL-palvelimen käynnistäminen
7. MySQL: n onnistuneen asennuksen jälkeen on aika käynnistää MySQL-palvelin seuraavalla komennolla:
# service mysqld start
Voit tarkistaa MySQL-palvelimen tilan seuraavan komennon avulla.
# service mysqld status
Tämä on esimerkki MySQL: n suorittamisesta CentOS 7 -ruudussa.
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. Tarkista lopuksi asennettu MySQL-versio seuraavalla komennolla.
# mysql --version mysql Ver 8.0.12 for Linux on x86_64 (MySQL Community Server - GPL)
Vaihe 5: MySQL-asennuksen suojaaminen
9. Komennolla mysql_secure_installation voit suojata MySQL-asennuksesi suorittamalla tärkeitä asetuksia, kuten asettamalla pääkäyttäjän salasanan, poistamalla tuntemattomat käyttäjät, poistamalla pääkäyttäjän kirjautumisen ja niin edelleen.
Huomautus: MySQL-versio 8.0 tai uudempi generoi väliaikaisen satunnaisen salasanan asennuksessa asennuksen jälkeen /var/log/mysqld.log
.
Käytä alla olevaa komentoa nähdäksesi salasanan ennen MySQL Secure -komennon suorittamista.
# grep 'temporary password' /var/log/mysqld.log
Kun tiedät salasanan, voit nyt suorittaa seuraavan komennon suojaamaan MySQL-asennuksesi.
# mysql_secure_installation
Huomaa: Anna uusi pääsalasana tarkoittaa väliaikaista salasanaa tiedostosta /var/log/mysqld.log
.
Seuraa nyt näytön ohjeita huolellisesti, katso viitteenä yllä olevan komennon lähtö.
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!
Vaihe 6: Yhdistäminen MySQL-palvelimeen
10. Yhdistäminen äskettäin asennettuun MySQL-palvelimeen antamalla käyttäjänimi ja salasana.
# 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>
Vaihe 7: MySQL: n päivittäminen Yumilla
11. Tuoreen asennuksen lisäksi voit myös tehdä päivityksiä MySQL-tuotteille ja -komponenteille seuraavan komennon avulla.
# yum update mysql-server # dnf update mysql-server [On Fedora versions]
Kun MySQL: lle on saatavana uusia päivityksiä, se asentaa ne automaattisesti, jos ei, saat viestin, jossa sanotaan EI päivityksiin merkittyjä paketteja.
Siinäpä, olet asentanut MySQL 8.0: n onnistuneesti järjestelmääsi. Jos sinulla on ongelmia asennuksen kanssa, voit käyttää ratkaisuja kommenttiosastollamme.