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 output=$(ec2metadata --instance-id); Used for storing EC2 ID. mysql -u root -pOldPassword UPDATE mysql.user
Now pass instance-id and use it to set a new password for mysql root.
SET authentication_string = PASSWORD('$output'), password_expired = 'N' WHERE User = 'root' AND Host = 'localhost'; FLUSH PRIVILEGES; EXIT