I have tried many different ways to interact with the mysql to reset the root mysql pass.
This is what I got to right now ...
Code:
#!/bin/sh
newpass=$1
service mysqld stop
mysqld_safe --skip-grant-tables --skip-networking &
echo "use mysql;" >> /tmp/mysql_pass_reset.txt
echo "update user set password=PASSWORD(\"$newpass\") where User=\"root\";" >> /tmp/mysql_pass_reset.txt
echo "FLUSH PRIVILEGES;" >> /tmp/mysql_pass_reset.txt
mysql -h localhost -uroot < /tmp/mysql_pass_reset.txt
service mysqld stop
service mysqld start
rm -rf /tmp/mysql_pass_reset.txt
If i run the commands manually, it works - but automatically with bash it doesn't.
This however, tested and all, doesn't seem to work. It doesn't really update the pass with the new one. And any password will work and drop the user into mysql console aswell.
Am I missing something? :P
ty