Reference: How to pass password to mysql command line
I want to grab returned metadata from an AWS EC2 instance and set a new mysql password based on this data.
I need assistance with the script which will run as first boot.
#!/bin/bash
ec2metadata --instance-id; Need to store echoed response.
mysql -u root -pOldPassword
UPDATE mysql.user
Now pass instance-id and use it to set new password for mysql root.
SET authentication_string = PASSWORD('instance-id'), password_expired = 'N'
WHERE User = 'root' AND Host = 'localhost';
FLUSH PRIVILEGES;
EXIT