GNU/Linux >> Linux Esercitazione >  >> Fedora

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

Mysql è comunemente installato come parte del popolare stack LAMP o LEMP (Linux, Apache/Nginx, MySQL/MariaDB, PHP/Python/Perl). Implementa il modello relazionale e il Structured Query Language (SQL) per gestire e interrogare i dati.

In questa guida installeremo mysql 8 su Fedora 34/35

Contenuti correlati

  • Come installare e configurare Mariadb in Fedora 35
  • Come installare Mysql 8 su Rocky Linux/Centos 8
  • Come installare e configurare mysql 8 su Ubuntu 20.04
  • Come eseguire Mysql 8 con Docker e Docker-Compose
  • Utilizzo di Ansible per installare e inizializzare Mysql 8 su Centos 8
  • Autorizzazioni MySQL:crea, aggiorna, elimina utenti del database
  • Installa e configura Nginx, WordPress e Mysql 8 in Centos 8
  • Crea un'istanza RDS in terraform con un esempio Mariadb

Indice dei contenuti

  1. Assicurarsi che il server sia aggiornato
  2. Installazione del server MySQL 8
  3. Avvio e abilitazione del servizio MySQL
  4. Protezione dell'installazione di MySQL
  5. Test dell'installazione di MySQL

Garantire che il server sia aggiornato

Prima di procedere, assicuriamoci che il nostro server Fedora sia aggiornato. Utilizzare questo comando per aggiornare i pacchetti del server:

sudo dnf -y update

Installazione del server MySQL 8

Ora che i nostri pacchetti sono aggiornati, possiamo procedere all'installazione del server mysql. Usa questo comando per cercare il pacchetto sul server che fornisce il server MySQL.

$ sudo dnf search mysql-server
Last metadata expiration check: 2:06:28 ago on Sun 31 Oct 2021 06:18:24 AM UTC.
========================================================================================= Name Matched: mysql-server ==========================================================================================
community-mysql-server.x86_64 : The MySQL server and related files

Usa questo comando per controllare le informazioni del pacchetto elencato per confermare che fornisce la versione di MySQL che desideriamo:

$ sudo dnf info community-mysql-server
Last metadata expiration check: 2:12:13 ago on Sun 31 Oct 2021 06:18:24 AM UTC.
Installed Packages
Name         : community-mysql-server
Version      : 8.0.26
Release      : 1.fc34
Architecture : x86_64
Size         : 106 M
Source       : community-mysql-8.0.26-1.fc34.src.rpm
Repository   : @System
From repo    : updates
Summary      : The MySQL server and related files
URL          : http://www.mysql.com
License      : GPLv2 with exceptions and LGPLv2 and BSD
Description  : MySQL is a multi-user, multi-threaded SQL database server. MySQL is a
             : client/server implementation consisting of a server daemon (mysqld)
             : and many different client programs and libraries. This package contains
             : the MySQL server and some accompanying files and directories.

Ora installa usando questo comando:

sudo dnf install -y community-mysql-server

Una volta installato, verifica l'installazione utilizzando questo comando:

$ rpm -qi community-mysql-server
Name        : community-mysql-server
Version     : 8.0.26
Release     : 1.fc34
Architecture: x86_64
Install Date: Sun 31 Oct 2021 08:28:55 AM UTC
Group       : Unspecified
Size        : 111652520
License     : GPLv2 with exceptions and LGPLv2 and BSD
Signature   : RSA/SHA256, Tue 17 Aug 2021 04:01:38 PM UTC, Key ID 1161ae6945719a39
Source RPM  : community-mysql-8.0.26-1.fc34.src.rpm
Build Date  : Wed 11 Aug 2021 09:34:44 PM UTC
Build Host  : buildvm-x86-18.iad2.fedoraproject.org
Packager    : Fedora Project
Vendor      : Fedora Project
URL         : http://www.mysql.com
Bug URL     : https://bugz.fedoraproject.org/community-mysql
Summary     : The MySQL server and related files
Description :
MySQL is a multi-user, multi-threaded SQL database server. MySQL is a
client/server implementation consisting of a server daemon (mysqld)
and many different client programs and libraries. This package contains
the MySQL server and some accompanying files and directories.

Avvio e abilitazione del servizio MySQL

Fino a questo punto siamo riusciti ad installare il servizio mysql nel nostro sistema. Il servizio non verrà avviato per impostazione predefinita, quindi dovremo iniziare emettendo il seguente comando:

sudo systemctl start mysqld

Per abilitare l'avvio del servizio al riavvio, utilizzare questo comando:

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

Ora controlla lo stato del servizio per confermare che sia effettivamente in esecuzione:

$ sudo systemctl status mysqld
● mysqld.service - MySQL 8.0 database server
     Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
     Active: active (running) since Sun 2021-10-31 08:37:07 UTC; 1min 21s ago
   Main PID: 55677 (mysqld)
     Status: "Server is operational"
      Tasks: 37 (limit: 4603)
     Memory: 449.0M
        CPU: 3.328s
     CGroup: /system.slice/mysqld.service
             └─55677 /usr/libexec/mysqld --basedir=/usr

Oct 31 08:36:58 new-cloud systemd[1]: Starting MySQL 8.0 database server...
Oct 31 08:36:58 new-cloud mysql-prepare-db-dir[55597]: Initializing MySQL database
Oct 31 08:37:07 new-cloud systemd[1]: Started MySQL 8.0 database server.

Il Active: active (running) since ... indica che il servizio è attivo e funzionante.

Per visualizzare il log del servizio MySQL 8 come segue, utilizzando il comando journalctl:

$ sudo journalctl -u mysqld -xe
$ sudo tail -f /var/log/mysql/mysqld.log

Protezione dell'installazione di MySQL

MySQL include uno script di sicurezza che consente di modificare alcune opzioni di configurazione predefinite per migliorare la sicurezza di MySQL.

Per utilizzare lo script di sicurezza, eseguire il comando seguente:

sudo mysql_secure_installation

Questo ti guiderà attraverso una serie di prompt che ti chiedono se desideri apportare determinate modifiche alle opzioni di sicurezza dell'installazione di MySQL. Queste opzioni includono:

  • impostazione della password utente root
  • abilitazione del COMPONENTE CONVALIDA PASSWORD che garantisce l'utilizzo di password complesse
  • Rimozione degli utenti anonimi
  • Disabilitazione root per accedere in remoto
  • Rimozione dei database di test

Ecco un esempio di output dal mio server:

$ sudo mysql_secure_installation

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: 2
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!

Test dell'installazione di MySQL

Controlliamo la versione di MySQL con questo comando:

$ mysql -V
mysql  Ver 8.0.26 for Linux on x86_64 (Source distribution)

Ora puoi accedere come root utente e la password sopra specificata.

$ 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.26 Source distribution

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

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>
mysql> select version();
+-----------+
| version() |
+-----------+
| 8.0.26    |
+-----------+
1 row in set (0.00 sec)

Conclusione

In questo articolo, siamo riusciti a installare e testare l'installazione di mysql 8 su Fedora 34/35


Fedora
  1. Come installare Skype su Fedora 35/34

  2. Come installare Apache Maven su Fedora 35/34

  3. Come installare e configurare Redis 6 su Fedora 34

  4. Come installare e configurare Mariadb in Fedora 35

  5. Come installare e utilizzare Podman in Fedora 34/35

Come installare LibreOffice su Fedora 35/34/33

Come installare Wine 6.0 su Fedora 35/34/33

Come installare Notepad++ su Fedora 35/34

Come installare e configurare Drupal su Fedora 35/34

Come installare TeamViewer su Fedora 35/34

Come installare e configurare MySQL su Ubuntu 18.04