Hello,
I'm trying to write a fairly simple bash script that installs mysql via yum (this is FC9) and sets the root password upon install.
Apparently the password is not being set properly as after I run the password script (I separated it from the install for testing purposes), I cannot log in.
Here is what I have for the password change script:
I have also tried it with the following line
Once mysql is installed, I start the service using: "service mysqld start" and then run the above script. After the script completes I then proceed to login using "mysql -p" and entering the same password as I used during the script. It fails with a response saying that Access denied for user 'root'@'localhost' (using password: YES)'.
Can anybody see what might be going wrong?
Thanks.
I'm trying to write a fairly simple bash script that installs mysql via yum (this is FC9) and sets the root password upon install.
Apparently the password is not being set properly as after I run the password script (I separated it from the install for testing purposes), I cannot log in.
Here is what I have for the password change script:
Code:
#!/bin/bash
mysqlPassword=""
mysqlPasswordRetype="s"
while [[ "$mysqlPassword" = "" && "$mysqlPassword" != "$mysqlPasswordRetype" ]]; do
echo -n "Please enter the desired mysql root password: "
stty -echo
read mysqlPassword
echo
echo -n "Retype password: "
read mysqlPasswordRetype
stty echo
echo
if [ "$mysqlPassword" != "$mysqlPasswordRetype" ]; then
echo "Passwords do not match!"
fi
done
/usr/bin/mysqladmin -u root password '${mysqlPassword}'
I have also tried it with the following line
Code:
/usr/bin/mysqladmin -u root password '$mysqlPassword'
Once mysql is installed, I start the service using: "service mysqld start" and then run the above script. After the script completes I then proceed to login using "mysql -p" and entering the same password as I used during the script. It fails with a response saying that Access denied for user 'root'@'localhost' (using password: YES)'.
Can anybody see what might be going wrong?
Thanks.