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

Come installare MySQL 8.0 su CentOS/RHEL 8

MySQL è un sistema di gestione di database relazionali open source. Attualmente, è in fase di sviluppo sotto Oracle Corporation. MySQL 8 è l'ultima versione disponibile per l'installazione e l'utilizzo dell'applicazione di produzione. MySQL 8.0 ha molti miglioramenti e una velocità di elaborazione 2x rispetto alla versione precedente. In questa versione, il team MySQL include l'archivio documenti per lo sviluppo di applicazioni di documenti SQL e NoSQL utilizzando un unico database.

Questo tutorial ti aiuterà a installare MySQL 8 sui sistemi CentOS 8 e RHEL 8.

Prerequisiti

Devi disporre dell'accesso alla shell con un account privilegiato sudo sul sistema CentOS 8.

Passaggio 1:installazione di MySQL

I pacchetti MySQL 8 sono disponibili nel repository AppStrem in CentOS 8. Installa i pacchetti richiesti utilizzando il comando seguente. Questo installerà anche più pacchetti dipendenti.

sudo dnf -y install @mysql

Dopo aver completato l'installazione, abilitare l'avvio automatico del servizio MySQL all'avvio del sistema. Avvia anche il servizio manualmente per la prima volta.

sudo systemctl enable mysqld.service
sudo systemctl start mysqld.service

Quindi controlla lo stato corrente del servizio utilizzando il seguente comando:

sudo systemctl status mysqld.service
● mysqld.service - MySQL 8.0 database server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2020-02-25 04:43:13 UTC; 22s ago
 Main PID: 16666 (mysqld)
   Status: "Server is operational"
    Tasks: 39 (limit: 17963)
   Memory: 534.9M
   CGroup: /system.slice/mysqld.service
           └─16666 /usr/libexec/mysqld --basedir=/usr

Feb 25 04:43:04 tecadmin systemd[1]: Starting MySQL 8.0 database server...
Feb 25 04:43:04 tecadmin mysql-prepare-db-dir[16582]: Initializing MySQL database
Feb 25 04:43:13 tecadmin systemd[1]: Started MySQL 8.0 database server.

Fase 2:installazione sicura di MySQL

L'installazione di MySQL è stata completata. Ora puoi connettere il server MySQL senza alcuna password, ma ti consigliamo di proteggere l'installazione di MySQL. I pacchetti MySQL forniscono mysql_secure_installation comando per applicare la sicurezza. Basta eseguire il comando seguente sul terminale:

sudo mysql_secure_installation

e segui le istruzioni sullo schermo. Di seguito sono riportati i dettagli che richiedono l'input dell'utente.

  • Premi y|Y per Sì, qualsiasi altro tasto per No:y
  • Inserisci 0 =BASSO, 1 =MEDIO e 2 =FORTE:2
  • Nuova password:[INSERIRE QUI LA PASSWORD FORTE]
  • Reinserire la nuova password:REinserire QUI LA PASSWORD
  • Vuoi continuare con la password fornita?(Premi y|Y per Sì, qualsiasi altro tasto per No) :y
  • Rimuovere utenti anonimi? (Premi y|Y per Sì, qualsiasi altro tasto per No) :y
  • Non consentire l'accesso root in remoto? (Premi y|Y per Sì, qualsiasi altro tasto per No) :y
  • Rimuovere il database dei test e accedervi? (Premi y|Y per Sì, qualsiasi altro tasto per No) :y
  • Ricaricare ora le tabelle dei privilegi? (Premi y|Y per Sì, qualsiasi altro tasto per No) :y

Fase 3:connetti MySQL

Hai terminato l'installazione e protetto il server MySQL. Ora connettiti al server MySQL tramite console o installa phpMyAdmin per utilizzare un'interfaccia web grafica.

mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.17 Source distribution

Copyright (c) 2000, 2019, 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>

Fase 4:crea database e utente

Non è consigliabile utilizzare utenti "root" per connettere i database dalle applicazioni. Quindi è una buona idea creare un utente separato per la connessione al database dell'applicazione. Di seguito sono riportati i comandi per creare un nuovo database MySQL, quindi creare un nuovo utente MySQL e assegnare privilegi sul database.

È possibile modificare il database e il nome utente in base alle proprie esigenze. Inoltre, utilizza una password complessa per l'utente.

mysql> CREATE DATABASE tecadmin;
Query OK, 1 row affected (0.01 sec)

mysql> CREATE USER 'tecadmin'@'localhost' IDENTIFIED BY 'your secure password here';
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT ALL ON tecadmin.* to 'tecadmin'@'localhost';
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

Ora, connettiti al server MySQL usando l'utente appena creato ed elenca i database disponibili.

mysql -u tecadmin -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.17 Source distribution

Copyright (c) 2000, 2019, 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> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| tecadmin           |
+--------------------+
2 rows in set (0.01 sec)

mysql>

Conclusione

Hai installato e configurato correttamente MySQL 8.0 sul sistema CentOS 8. Il tuo server è pronto per l'uso in produzione. Potrebbe anche essere necessario configurare lo script di backup automatico del database per il sistema di produzione.


Cent OS
  1. Come installare il server database MySQL 8 su CentOS 8

  2. Come installare SpaceWalk su CentOS 6 / RHEL 6

  3. Come installare PostgreSQL su CentOS 7 / RHEL 7

  4. Come installare SpaceWalk su CentOS 7 / RHEL 7

  5. Come installare MariaDB 10.4 su CentOS 8 e RHEL 8

Come installare phantomjs su RHEL 8 / CentOS 8

Come installare Dropbox su RHEL 8 / CentOS 8

Come installare MySQL su CentOS 8

Come installare Cacti su CentOS 6 / RHEL 6

Come installare MySQL 8.0 su CentOS 8 / RHEL 8

Come installare Cacti su CentOS 8 / RHEL 8