Skip to main content
Improved logic of script so it easier to follow.
Source Link

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;id); NeedUsed tofor storestoring echoedEC2 responseID.    

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('instance-id''$output'), password_expired = 'N'
WHERE User = 'root' AND Host = 'localhost';

FLUSH PRIVILEGES;

EXIT

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

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
Add reference to other question, Some wording/grammar/formatting improved
Source Link

Reference: How to pass password to mysql command line

NeedI want to grab returned metadata from an AWS EC2 instance and set a new mysql password based on this data. Need

I need assistance with the script. Keep in mind that this 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

Reference: How to pass password to mysql command line

Need to grab returned metadata from an AWS EC2 instance and set new mysql password based on this data. Need assistance with the script. Keep in mind that this script 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

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
added link
Source Link
Jeff Schaller
  • 68.8k
  • 35
  • 122
  • 265

Ref post#205180Reference: How to pass password to mysql command line

Need to grab returned metadata from an AWS EC2 instance and set new mysql password based on this data. Need assistance with the script. Keep in mind that this script 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

Ref post#205180

Need to grab returned metadata from an AWS EC2 instance and set new mysql password based on this data. Need assistance with the script. Keep in mind that this script 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

Reference: How to pass password to mysql command line

Need to grab returned metadata from an AWS EC2 instance and set new mysql password based on this data. Need assistance with the script. Keep in mind that this script 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
Source Link
Loading