#!/bin/bash

[ "$(CreoleGet activer_mysql)" = "non" ] && exit 0

plugin=$(CreoleRun "mysql --defaults-file=/etc/mysql/debian.cnf --skip-column-names --batch -e 'use mysql;select plugin from user where user=\"root\" and plugin=\"auth_socket\";'" "mysql")

[ $? -ne 0 ] && exit 0

if [ "${plugin##plugin}" = "auth_socket" ];then
    echo "Modification du plugin d'authentification pour l'utilisateur root";
    CreoleRun "mysql --defaults-file=/etc/mysql/debian.cnf --skip-column-names --batch -e 'use mysql;update user set plugin=\"mysql_native_password\" where user=\"root\";flush privileges;'" "mysql"
fi

exit 0
