Installer MySQL

Installez votre serveur de base de données :

sudo apt-get install mysql-client mysql-server

Lors de l'installation, le service vous demandera de définir un mot de passe pour le compte d'administration MySQL et de le confirmer :

Sécuriser l'installation avec la commande suivante :


Résultat :


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

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

You already have a root password set, so you can safely answer 'n'.

Change the root password? [Y/n] n
 ... skipping.

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? [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, 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? [Y/n] y
 - Dropping test database...
ERROR 1008 (HY000) at line 1: Can't drop database 'test'; database doesn't exist
 ... Failed!  Not critical, keep moving...
 - 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 MySQL
installation should now be secure.

Thanks for using MySQL!

Vous pouvez vérifier le bon fonctionnement de votre service en tapant la commande suivante :

/etc/init.d/mysql status

Une réponse s'affiche :

● mysql.service - LSB: Start and stop the mysql database server daemon
   Loaded: loaded (/etc/init.d/mysql)
   Active: active (running) since dim. 2017-05-07 06:20:21 EDT; 44min ago
   CGroup: /system.slice/mysql.service
           ├─23489 /bin/sh /usr/bin/mysqld_safe
           └─23834 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --log-error=/var/log/mysql/error.log --pid-file=/var/run/mysqld/ --socket=...

mai 07 06:20:24 /etc/mysql/debian-start[23894]: mysql.help_category                                OK
mai 07 06:20:24 /etc/mysql/debian-start[23894]: mysql.help_keyword                                 OK
mai 07 06:20:24 /etc/mysql/debian-start[23894]: mysql.help_relation                                OK
mai 07 06:20:24 /etc/mysql/debian-start[23894]: mysql.help_topic                                   OK
mai 07 06:20:24 /etc/mysql/debian-start[23894]:                                         OK
mai 07 06:20:24 /etc/mysql/debian-start[23894]: mysql.ndb_binlog_index                             OK
mai 07 06:20:24 /etc/mysql/debian-start[23894]: mysql.plugin                                       OK
mai 07 06:20:24 /etc/mysql/debian-start[23894]: mysql.proc                                         OK
mai 07 06:20:24 /etc/mysql/debian-start[23894]: mysql.procs_priv                                   OK
mai 07 06:20:24 /etc/mysql/debian-start[23894]: mysql.proxies_priv                                 OK

Vous pouvez vérifier en ligne de commande le service :

mysql -uroot -pVotreMotDePasse_lors_de_l_installation

Résultat :

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 43
Server version: 5.5.55-0+deb8u1 (Debian)

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

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


Une fois connecté tapez la commande :


Vous obtiendrez le résultat suivant :

| Database           |
| information_schema |
| mysql              |
| performance_schema |
3 rows in set (0.00 sec)
  • informatique/installer_mysql.txt
  • Dernière modification: 2017/05/07 22:34
  • par Cedric ABONNEL