Afin d'automatiser l'installation de MySQL sous Debian, Ansible est l'outils qu'il nous faut.
L'upgrade vers MySQL 8.0 ne peut se faire que depuis :
--- # Upgrade vers MySQL 8.0 sur Debian - hosts: mysql vars: debian_name: buster mysql_version: 8.0 source_directory: /root/playbooks/mysql_upgrade_8.0 remote_user: root tasks: - name: copy apt repository file template: src: "{{ source_directory }}/mysql.list" dest: /etc/apt/sources.list.d/mysql.list - name: Stop mysql service systemd: name: mysql state: stopped - name: configure package installation ... authentication method debconf: name: mysql-community-server question: mysql-server/default-auth-override value: Use Strong Password Encryption (RECOMMENDED) vtype: select - name: install mysql apt: name: mysql-server state: latest update_cache: yes environment: DEBIAN_FRONTEND: noninteractive
deb http://repo.mysql.com/apt/debian/ {{ debian_name }} mysql-{{ mysql_version }}
# ansible-playbook mysql_upgrade_8.0.yml PLAY [mysql] ****************************************************************************************************************************************** TASK [Gathering Facts] ******************************************************************************************************************************** ok: [mysql03] TASK [copy apt repository file] *********************************************************************************************************************** changed: [mysql03] TASK [Stop mysql service] ***************************************************************************************************************************** changed: [mysql03] TASK [configure package installation ... authentication method] *************************************************************************************** changed: [mysql03] TASK [install mysql] ********************************************************************************************************************************** changed: [mysql03] PLAY RECAP ******************************************************************************************************************************************** mysql03 : ok=5 changed=4 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0Le fichier /var/log/mysql/error.log témoigne de l'upgrade MySQL et du démmarage automatique après upgrade:
2021-08-25T12:54:12.050942Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.26) starting as process 1476 2021-08-25T12:54:12.077286Z 1 [System] [MY-011012] [Server] Starting upgrade of data directory. 2021-08-25T12:54:12.078046Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started. 2021-08-25T12:54:12.887347Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended. 2021-08-25T12:54:14.917908Z 2 [System] [MY-011003] [Server] Finished populating Data Dictionary tables with data. 2021-08-25T12:54:16.188587Z 5 [System] [MY-013381] [Server] Server upgrade from '50700' to '80026' started. 2021-08-25T12:54:22.779981Z 5 [System] [MY-013381] [Server] Server upgrade from '50700' to '80026' completed. 2021-08-25T12:54:22.883080Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1 is enabled for channel mysql_main 2021-08-25T12:54:22.883558Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1.1 is enabled for channel mysql_main 2021-08-25T12:54:22.890471Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed. 2021-08-25T12:54:22.890988Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel. 2021-08-25T12:54:22.919390Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock 2021-08-25T12:54:22.919644Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.26' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server - GPL.