#!/bin/bash pass=`date +%s%D%N; cat /etc/hostname; uname -a; ip addr` hash=`echo $pass | sha256sum | base64 | head -c 18` echo "[!!] New password: "$hash echo service mysql stop sleep 4 mysqld_safe --skip-grant-tables & sleep 4 mysql -uroot -e "use mysql; update user set password=PASSWORD('$hash') where User='root'; flush privileges;" kill -9 `pidof /bin/sh /usr/bin/mysqld_safe` service mysql start echo 'Done' echo "[client] #user=root #password=$hash " >> /root/.my.cnf nano /root/.my.cnf