Ricerca nel sito web

Come installare l'ultimo database MariaDB su Ubuntu 22.04


Su questa pagina

  1. Prerequisiti
  2. Aggiungi il repository MariaDB
  3. Installa e configura MariaDB
  4. Verifica la versione di MariaDB
  5. Conclusione

MariaDB è un fork gratuito, open-source e del popolare sistema di database MySQL. È un sistema di gestione di database relazionali ampiamente utilizzato realizzato dagli sviluppatori originali di MySQL. È appositamente progettato per la scalabilità e le distribuzioni mission-critical. Per impostazione predefinita, il pacchetto MariaDB è disponibile nel repository predefinito di tutte le principali distribuzioni Linux. Al momento della stesura di questo tutorial, l'ultima versione di MariaDB è la 10.8. Ogni major release verrà mantenuta per almeno 5 anni. Quindi MariaDB 10.8.0 sarà supportato fino al 2027.

In questo tutorial, ti mostreremo come installare MariaDB 10.8 sul server Ubuntu 22.04.

Prerequisiti

  • Un server che esegue Ubuntu 22.04.
  • Sul server è configurata una password di root.

Aggiungi il repository MariaDB

Per impostazione predefinita, l'ultima versione di MariaDB non è disponibile nel repository standard di Ubuntu 22.04. Quindi dovrai aggiungere il repository ufficiale MariaDB al tuo sistema.

Innanzitutto, installa tutte le dipendenze richieste con il seguente comando:

apt-get install software-properties-common gnupg2 -y

Una volta installate tutte le dipendenze, importare la chiave di firma MariaDB con il seguente comando:

apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc'

Dovresti ottenere il seguente output:

Executing: /tmp/apt-key-gpghome.kGFC5Ag1H8/gpg.1.sh --fetch-keys https://mariadb.org/mariadb_release_signing_key.asc
gpg: requesting key from 'https://mariadb.org/mariadb_release_signing_key.asc'
gpg: key F1656F24C74CD1D8: public key "MariaDB Signing Key <>" imported
gpg: Total number processed: 1
gpg:               imported: 1

Successivamente, aggiungi il repository MariaDB con il seguente comando:

add-apt-repository 'deb [arch=amd64] http://mariadb.mirror.globo.tech/repo/10.8/ubuntu jammy main'

Una volta aggiunto il repository, aggiorna il repository con il seguente comando:

apt-get update -y

A questo punto, il repository MariaDB viene aggiunto e aggiornato. Ora puoi procedere al passaggio successivo.

Installa e configura MariaDB

Ora, installa l'ultima versione del server e del client MariaDB con il seguente comando:

apt-get install mariadb-server mariadb-client -y

Al termine dell'installazione, avvia il servizio MariaDB e abilitalo per l'avvio al riavvio del sistema:

systemctl start mariadb
systemctl enable mariadb

Successivamente, dovrai proteggere l'installazione di MariaDB e impostare la password di root di MariaDB. Puoi farlo eseguendo il seguente script:

mysql_secure_installation

Ti verrà chiesto di fornire la tua attuale password di root come mostrato di seguito:

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.

Enter current password for root (enter for none): 

Basta premere Invio. Ti verrà chiesto di passare all'autenticazione unix_socket come mostrato di seguito:

OK, successfully used password, moving on...

Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorization.

You already have your root account protected, so you can safely answer 'n'.

Switch to unix_socket authentication [Y/n] Y

Digita Y e premi Invio. Ti verrà chiesto di modificare la password di root come mostrato di seguito:

Enabled successfully!
Reloading privilege tables..
 ... Success!


You already have your root account protected, so you can safely answer 'n'.

Change the root password? [Y/n] Y

Digita Y e premi Invio per modificare la password di root.

New password: 
Re-enter new password: 

Fornisci la tua password sicura e premi Invio. Dovresti vedere il seguente output:

Password updated successfully!
Reloading privilege tables..
 ... Success!


Next, you will be asked to remove anonymous users as shown below:

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB 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? [Y/n] Y

Digita Y e premi Invio per rimuovere gli utenti anonimi. Ti verrà chiesto di non consentire l'accesso root remoto come mostrato di seguito:

 ... 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? [Y/n] Y

Digita Y e premi Invio. Ti verrà chiesto di rimuovere un database di test come mostrato di seguito:

 ... Success!

By default, MariaDB 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? [Y/n] Y

Digita Y e premi Invio per rimuovere il database di test. Ti verrà chiesto di ricaricare le tabelle dei privilegi come mostrato di seguito:

 - 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? [Y/n] Y

Digita Y e premi Invio, dovresti vedere il seguente output:

 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

Verifica la versione di MariaDB

A questo punto, MariaDB è installato e protetto. Successivamente, dovrai verificare la versione installata di MariaDB.

Innanzitutto, accedi alla shell MariaDB con il seguente comando:

mysql -u root -p

Fornisci la tua password di root MariaDB e premi Invio. Una volta effettuato il login, dovresti vedere il seguente output:

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 31
Server version: 10.8.3-MariaDB-1:10.8.3+maria~jammy mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> 

Esegui il seguente comando per verificare la versione di MariaDB:

MariaDB [(none)]> SELECT VERSION();

Dovresti ottenere il seguente output:

+-------------------------------------+
| VERSION()                           |
+-------------------------------------+
| 10.8.3-MariaDB-1:10.8.3+maria~jammy |
+-------------------------------------+
1 row in set (0.000 sec)

Conclusione

In questo post, abbiamo spiegato come installare l'ultimo database MariaDB sul server Ubuntu 22.04. Abbiamo anche spiegato come proteggere MariaDB e verificare la versione di MariaDB. Ora puoi connetterti a MariaDB e iniziare a creare un database, un utente e integrarlo con la tua applicazione.