Salta al contenuto principale
MySQL Ubuntu 24.04 Noble Numbat

Installare MySQL in Ubuntu 24.04 Noble Numbat

In questa guida vedremo come installare MySQL 8.0 in Ubuntu 24.04 Noble Numbat con apt, il gestore di pacchetti di default

È molto comune nei nostri interventi di Assistenza Linux, essendo la base per gli stack LAMP (Linux, Apache, MySQL, PHP), LEMP (NginX) e svariati altri, necessari per webapp, CMS ed e-Commerce

Installare MySQL in Ubuntu

Come primo passaggio aggiorniamo la lista dei pacchetti disponibili con

sudo apt update

Procediamo ad installare Mysql con quasto comando

sudo apt install mysql-server-8.0

Il server dovrebbe essere già attivo, controlliamo se il processo è attivo

sudo service mysql status

Nel caso non sia attivo possiamo riavviare MySQL e ripetere il controllo

sudo service mysql restart
* Stopping MySQL database server mysqld                         [ OK ]
* Starting MySQL database server mysqld [ OK ]

Controlliamo la porta default di MySQL, la 3306 TCP, che a questo punto dovrebbe essere in ascolto

sudo apt install net-tools
sudo netstat -tnplu |grep 3306

Il comando deve restituirci l'output seguente, mostrando la porta 3306 in ascolto in locale

tcp    0      0 127.0.0.1:3306      0.0.0.0:*   LISTEN      -
tcp6   0      0 :::33060            :::*        LISTEN      -

Configurare MySQL

Il server è attivo, per una nuova installazione le configurazioni utilizzate sono quelle di default, la sicurezza è scarsa, a questo punto è consigliato eseguire lo script di configurazione del DBMS per settare le autenticazioni e rimuovere gli accessi anonimi

sudo mysql_secure_installation

Lo script ci guiderà nella configurazione delle opzioni di sicurezza del server

Come prima cosa abilitiamo il controllo delle password per gli utenti, e selezioniamo le password forti, con ricerca a dizionario di password comuni

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
Skipping password set for root as authentication with auth_socket is used by default.
If you would like to use password authentication instead, this can be done with the "ALTER_USER" command.
See https://dev.mysql.com/doc/refman/8.0/en/alter-user.html#alter-user-password-management for more information.

Rimuoviamo gli utenti anonimi, per aumentare la sicurezza

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

Configuriamo autenticazione locale dell'utente root, che avverrà tramite socket, solamente sulla macchina locale

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

Rimuoviamo i database di test, inutili in produzione

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

Effettuiamo il reload delle tabelle dei privilegi, in modo da applicare le nostre modifiche immediatamente.

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

Accesso root a MySQL

L'installazione è terminata è possiamo accedere con l'utente root

sudo mysql -u root
show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

L'output ci indica i database presenti, siamo riusciti a installare MySQL in Ubuntu 24.04, possiamo utilizzare con la solita sintassi il nostro MySQL, connettere ne nostre web app e CMS

Aggiungi un commento

Text Only

  • Nessun tag HTML consentito.