dimanche 3 février 2008

bash pour changer de mot de passe mysql

#!/bin/bash
echo "entrer vote nouveau de passe :"
read mdp

touch /home/$USER/table && echo "#!/bin/bash
update user set password=password('$mdp') where user="root" and host="localhost";" > /home/$USER/table
chmod +x /home/$USER/table

sudo /etc/init.d/mysql stop
#puis redémarrer en mode safe pour changer les tables d'autorisation
sudo mysqld_safe --skip-grant-tables --skip-networking &
if [ "$?" == "0" ]
then
#définir le mot de passe mysql
mysql mysql < /home/$USER/table
fi

sudo /etc/init.d/mysql restart
rm /home/$USER/table
exit

Aucun commentaire: