Reset Password from Bash using EC2 ID
Hello,
I'd like to reset MySQL root on first boot using bash with a known default password. [Ubuntu]
So my assumption it will look something like this, but I do not know how to pass the EC2 instance ID as password to the mysql. Assistance appreciated.
#!/bin/bash
ec2metadata --instance-id
mysql -u root -p oldpassword
> UPDATE mysql.user
#Now pass EC2 instance ID and set new password for mysql
> SET authentication_string = PASSWORD('instance-id'), password_expired = 'N'
> WHERE User = 'root' AND Host = 'localhost';
mysql> FLUSH PRIVILEGES;
mysql> exit
Subject
Written By
Posted
Reset Password from Bash using EC2 ID
May 24, 2017 09:30PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.