GNU/Linux >> Linux Esercitazione >  >> Fedora

Come installare e configurare Mariadb in Fedora 35

MariaDB è stato sviluppato come fork software di MySQL nel 2009 in risposta all'acquisizione di MySQL da parte di Oracle. MariaDB intende rimanere un software libero e open source sotto la GNU General Public License. Fa parte della maggior parte delle offerte cloud ed è l'impostazione predefinita nella maggior parte delle distribuzioni Linux.

In questa guida impareremo come installare e configurare MariaDB in Fedora 35 Server/Workstation.

Post correlati

  • Come installare e configurare Mariadb 10 in Debian 11
  • Come installare e configurare Mariadb 10 in Ubuntu 20.04
  • Come installare e configurare Mysql Server 8 su Fedora 34/35
  • Come installare Mysql 8 su Rocky Linux/Centos 8
  • Come installare e configurare mysql 8 su Ubuntu 20.04

Prerequisiti

Per seguire, assicurati di avere:

  • Un server/workstation Fedora aggiornato
  • Accesso root al server o utente con accesso Sudo
  • Accesso a Internet dal server

Indice dei contenuti

  1. Aggiorna sistema
  2. Installazione di Mariadb
  3. Configurazione di Mariadb
  4. Testare MariaDB

1. Aggiorna il sistema

Prima di procedere assicuriamoci che il server Fedora sia aggiornato.

Nel tuo terminale, digita questi. Il -y opzione in dnf update è garantire che il sistema non si interrompa per accettare l'aggiornamento.

sudo dnf -y update

2. Installazione di mariadb

Mariadb può essere trovato nei repository predefiniti per Fedora. Utilizzare questo comando per installare il server di database. Puoi confermare cercando con questo comando:

sudo dnf search mariadb-server

Installa Mariadb usando questo comando

sudo dnf install -y mariadb-server

Avvio e abilitazione di Mariadb

Mariadb non verrà avviato per impostazione predefinita. Usa questo comando per iniziare:

sudo systemctl start mariadb

Verifica che il servizio sia attivo e funzionante controllandone lo stato

$ sudo systemctl status mariadb
● mariadb.service - MariaDB 10.5 database server
     Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
     Active: active (running) since Sat 2021-11-13 05:46:38 UTC; 18s ago
       Docs: man:mariadbd(8)
             https://mariadb.com/kb/en/library/systemd/
    Process: 9385 ExecStartPre=/usr/libexec/mariadb-check-socket (code=exited, status=0/SUCCESS)
    Process: 9408 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir mariadb.service (code=exited, status=0/SUCCESS)
    Process: 9504 ExecStartPost=/usr/libexec/mariadb-check-upgrade (code=exited, status=0/SUCCESS)
   Main PID: 9490 (mariadbd)
     Status: "Taking your SQL requests now..."
      Tasks: 13 (limit: 4585)
     Memory: 82.2M
        CPU: 460ms
     CGroup: /system.slice/mariadb.service
             └─9490 /usr/libexec/mariadbd --basedir=/usr

Nov 13 05:46:37 ip-10-2-40-174.us-west-2.compute.internal mariadb-prepare-db-dir[9448]: See the MariaDB Knowledgebase at https://mariadb.com/kb or the
Nov 13 05:46:37 ip-10-2-40-174.us-west-2.compute.internal mariadb-prepare-db-dir[9448]: MySQL manual for more instructions.
Nov 13 05:46:37 ip-10-2-40-174.us-west-2.compute.internal mariadb-prepare-db-dir[9448]: Please report any problems at https://mariadb.org/jira
Nov 13 05:46:37 ip-10-2-40-174.us-west-2.compute.internal mariadb-prepare-db-dir[9448]: The latest information about MariaDB is available at https://mariadb.org/.
Nov 13 05:46:37 ip-10-2-40-174.us-west-2.compute.internal mariadb-prepare-db-dir[9448]: You can find additional information about the MySQL part at:
Nov 13 05:46:37 ip-10-2-40-174.us-west-2.compute.internal mariadb-prepare-db-dir[9448]: https://dev.mysql.com
Nov 13 05:46:37 ip-10-2-40-174.us-west-2.compute.internal mariadb-prepare-db-dir[9448]: Consider joining MariaDB's strong and vibrant community:
Nov 13 05:46:37 ip-10-2-40-174.us-west-2.compute.internal mariadb-prepare-db-dir[9448]: https://mariadb.org/get-involved/
Nov 13 05:46:37 ip-10-2-40-174.us-west-2.compute.internal mariadbd[9490]: 2021-11-13  5:46:37 0 [Note] /usr/libexec/mariadbd (mysqld 10.5.12-MariaDB) starting as process 9490 ...
Nov 13 05:46:38 ip-10-2-40-174.us-west-2.compute.internal systemd[1]: Started MariaDB 10.5 database server.

Ora che è avviato, abilitiamo l'avvio all'avvio con questo:

$ sudo systemctl enable mariadb
Created symlink /etc/systemd/system/mysql.service → /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/mysqld.service → /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /usr/lib/systemd/system/mariadb.service.

3. Configurazione di MariaDB

Per le nuove installazioni di MariaDB, il passaggio successivo è eseguire lo script di sicurezza incluso. Questo script modifica alcune delle opzioni predefinite meno sicure. Lo useremo per bloccare il root remoto accessi e per rimuovere gli utenti del database inutilizzati.

Esegui lo script di sicurezza:

sudo mysql_secure_installation

Questo ti guiderà attraverso una serie di prompt in cui puoi apportare alcune modifiche alle opzioni di sicurezza dell'installazione di MariaDB. La prima richiesta ti chiederà di inserire il database corrente root parola d'ordine. Poiché non ne abbiamo ancora impostato uno, premi ENTER per indicare “nessuno”.

La richiesta successiva ti chiede se desideri configurare un database root parola d'ordine. Digita N e quindi premi ENTER . In Fedora, la radice l'account per MariaDB è strettamente legato alla manutenzione automatizzata del sistema, quindi non dovremmo modificare i metodi di autenticazione configurati per quell'account. Ciò consentirebbe a un aggiornamento del pacchetto di interrompere il sistema del database rimuovendo l'accesso all'account amministrativo. Successivamente, illustreremo come configurare facoltativamente un account amministrativo aggiuntivo per l'accesso tramite password se l'autenticazione socket non è appropriata per il tuo caso d'uso.

Da lì, puoi premere Y e poi ENTER accettare le impostazioni predefinite per tutte le domande successive. Ciò rimuoverà alcuni utenti anonimi e il database di test, disabiliterà il root remoto login e carica queste nuove regole in modo che MariaDB rispetti immediatamente le modifiche che hai apportato.

Questo è l'output del mio server

$ sudo mysql_secure_installation

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):
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 authorisation.

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

Switch to unix_socket authentication [Y/n] n
 ... skipping.

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

Change the root password? [Y/n]
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!


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

5. Test di MariaDB

Ora che mariadb è tutto configurato ed è in esecuzione, dobbiamo confermare che può accettare connessioni.

Per eseguire il test, connettiti a mariadb con l'utente root – mysql -h 127.0.0.1 -u root -p

Uscita:

$ mysql -h 127.0.0.1 -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 11
Server version: 10.5.12-MariaDB MariaDB Server

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

Controlla la versione di mariadb:

MariaDB [(none)]> SELECT VERSION();
+-----------------+
| VERSION()       |
+-----------------+
| 10.5.12-MariaDB |
+-----------------+
1 row in set (0.000 sec)

MariaDB [(none)]>

Per un ulteriore controllo, puoi provare a connetterti al database utilizzando il mysqladmin tool, che è un client che consente di eseguire comandi amministrativi. Ad esempio, questo comando dice di connettersi a MariaDB come root e restituire la versione utilizzando il socket Unix:

sudo mysqladmin version

Dovresti ricevere un output simile a questo:

$ sudo mysqladmin version
mysqladmin  Ver 9.1 Distrib 10.5.12-MariaDB, for Linux on x86_64
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Server version		10.5.12-MariaDB
Protocol version	10
Connection		Localhost via UNIX socket
UNIX socket		/var/lib/mysql/mysql.sock
Uptime:			5 min 38 sec

Threads: 1  Questions: 21  Slow queries: 0  Opens: 20  Open tables: 13  Queries per second avg: 0.062

Ciò significa che MariaDB è attivo e funzionante e che il tuo utente è in grado di autenticarsi correttamente.

Conclusione

In questa guida hai installato MariaDB per fungere da server SQL. Durante il processo di installazione hai anche protetto il server.


Fedora
  1. Come installare e configurare Mysql Server 8 su Fedora 34/35

  2. Come installare e configurare Redis 6 su Fedora 34

  3. Come installare e configurare Postgres 14 su Fedora 34

  4. Come installare e configurare Mariadb 10 in Ubuntu 20.04

  5. Come installare e configurare Mariadb 10 in Debian 11

Come installare e configurare Jenkins in Fedora 35

Come installare e configurare Git su Fedora 35

Come installare Redis e configurare su Fedora 35

Come installare WordPress su Fedora 35

Come installare MariaDB su Fedora 35

Come installare e configurare Grafana