GNU/Linux >> Linux Esercitazione >  >> Cent OS

Come installare il server database MySQL 8 su CentOS 8

MySQL è un sistema di database gratuito, open source e uno dei più popolari in tutto il mondo. È una piattaforma di gestione di database relazionali basata su Oracle Cloud. Utilizza Structured Query Language per aggiungere, accedere e gestire il contenuto in un database. È noto per la sua comprovata affidabilità, rapidità di elaborazione, facilità e flessibilità d'uso. Sono state aggiunte diverse nuove funzionalità in MySQL 8, tra cui supporto JSON, Transactional Data Dictionary, configurazione del runtime persistente, archivio documenti, suggerimenti per l'ottimizzatore, ruoli SQL, CTE e funzioni Window, indici invisibili e molti altri.

Nota :prima di installare MySQL 8, fai riferimento alla documentazione ufficiale in quanto MySQL 8 ha alcune nuove funzionalità e modifiche che hanno reso alcune applicazioni incompatibili con questa versione.

In questo tutorial, ti mostreremo come installare il database MySQL 8 sul server CentOS 8.

Prerequisiti

  • Un server che esegue CentOS 8.
  • È stata impostata una password di root sul tuo server.

Installa MySQL 8.0 da MySQL Repository

Per impostazione predefinita, MySQL 8.0 non è disponibile nel repository predefinito di CentOS 8. Quindi dovrai installare il repository della community MySQL 8.0 sul tuo sistema. Puoi installarlo con il seguente comando:

rpm -ivh https://dev.mysql.com/get/mysql80-community-release-el8-1.noarch.rpm

Dovresti vedere il seguente output:

Retrieving https://dev.mysql.com/get/mysql80-community-release-el8-1.noarch.rpm
warning: /var/tmp/rpm-tmp.hF0m5V: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Verifying...                          ################################# [100%]
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql80-community-release-el8-1  ################################# [100%]

Quindi, verifica se il repository MySQL 8.0 è stato abilitato o meno con il seguente comando:

dnf repolist all | grep mysql | grep enabled

Dovresti vedere il seguente output:

CentOS-8 - AppStream                            3.1 MB/s | 6.5 MB     00:02    
CentOS-8 - Base                                 3.0 MB/s | 5.0 MB     00:01    
CentOS-8 - Extras                               5.3 kB/s | 2.1 kB     00:00    
MySQL 8.0 Community Server                       24 MB/s | 543 kB     00:00    
MySQL Connectors Community                      1.9 MB/s |  19 kB     00:00    
MySQL Tools Community                           677 kB/s |  62 kB     00:00    
mysql-connectors-community         MySQL Connectors Community     enabled:    42
mysql-tools-community              MySQL Tools Community          enabled:    19
mysql80-community                  MySQL 8.0 Community Server     enabled:    31

Quindi, disabilita temporaneamente il repository AppStream e installa l'ultima versione di MySQL 8.0 dal repository della community MySQL con il seguente comando:

dnf --disablerepo=AppStream install mysql-community-server -y

Una volta che l'installazione è stata completata con successo, puoi verificare la versione installata di MySQL con il seguente comando:

mysql -Version

Dovresti vedere il seguente output:

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

Quindi, avvia il servizio MySQL e abilitalo all'avvio dopo il riavvio del sistema con il seguente comando:

systemctl start mysqld
systemctl enable mysqld

Puoi anche controllare lo stato di MySQL con il seguente comando:

systemctl status mysqld

Dovresti vedere il seguente output:

? mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2020-03-05 09:37:46 EST; 12s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 3244 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 3329 (mysqld)
   Status: "Server is operational"
    Tasks: 39 (limit: 12537)
   Memory: 587.7M
   CGroup: /system.slice/mysqld.service
           ??3329 /usr/sbin/mysqld

Mar 05 09:37:01 centos8 systemd[1]: Starting MySQL Server...
Mar 05 09:37:46 centos8 systemd[1]: Started MySQL Server.

Successivamente, è sempre una buona idea eseguire lo script mysql_secure_installation per abilitare alcune funzionalità di sicurezza aggiuntive, tra cui impostare una nuova password di root MySQL, rimuovere utenti anonimi e disabilitare l'accesso remoto.

Innanzitutto, trova la password di root predefinita di MySQL usando il seguente comando:

cat /var/log/mysqld.log | grep -i 'temporary password'

Uscita:

2020-03-05T14:37:40.273796Z 5 [Note] [MY-010454] [Server] A temporary password is generated for [email protected]: GN2uNx-vPqwS

Per favore, prendi nota della password sopra e cambiala usando lo script mysql_secure_installation.

mysql_secure_installation

Rispondi a tutte le domande come mostrato di seguito:

Securing the MySQL server deployment.

Enter password for user root:   Provide your temporary MySQL root password

The existing password for the user account root has expired. Please set a new password.

New password:   Provide new root password

Re-enter new password:   Re-enter new root password
The 'validate_password' component is installed on the server.
The subsequent steps will run with the existing configuration
of the component.
Using existing password for root.

Estimated strength of the password: 100 
Change the password for root ? ((Press y|Y for Yes, any other key for No) : N  Type N and Enter to continue

 ... skipping.
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!

Installa MySQL 8.0 da AppStream Repository

Puoi anche installare MySQL 8.0 dal repository AppStream predefinito su CentOS 8. Puoi installarlo con il seguente comando:

dnf install @mysql -y

Una volta completata l'installazione, controlla la versione di MySQL con il seguente comando:

mysql -Version

Dovresti vedere il seguente output:

mysql  Ver 8.0.17 for Linux on x86_64 (Source distribution)

Quindi, avvia il servizio MySQL e abilitalo all'avvio dopo il riavvio del sistema con il seguente comando:

systemctl start mysqld
systemctl enable mysqld

Per impostazione predefinita, la password di root MySQL non è impostata in CentoS 8. Quindi dovrai impostarla utilizzando lo script mysql_secure_installation.

mysql_secure_installation

Rispondi a tutte le domande come mostrato di seguito:

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD COMPONENT 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 component?

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: 0
Please set the password for root here.

New password: 

Re-enter new 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! 

Conclusione

Nella guida sopra, hai imparato come installare MySQL 8 dal repository della community MySQL e dal repository AppStream su CentOS 8. Ora puoi iniziare a creare un nuovo database e utenti di database.


Cent OS
  1. Come installare wordpress su CentOS 6

  2. Installa MySQL Server 5.6 in CentOS

  3. Come installare MySQL 8.0 su CentOS/RHEL 8

  4. Come installare il server di database MySQL su CentOS

  5. Come installare MySQL Server su CentOS 7

Come installare Nginx su CentOS 8

Come installare PostgreSQL su CentOS 8

Come installare MariaDB su CentOS 8

Come installare FreeIPA Server su CentOS 7

Come installare PostgreSQL Database Server CentOS 8

Come installare MySQL 8 su CentOS 8