I am trying to automate mysql_secure_installation script with automated response. My code is as follows :
echo "& y y abc abc y y y y" | ./usr/bin/mysql_secure_installation
The actual questions which i am automating are as follows:
Enter current password for root (enter for none): <enter> Set root password? [Y/n] y New password: abc Re-enter new password: abc Remove anonymous users? [Y/n] y Disallow root login remotely? [Y/n] y Remove test database and access to it? [Y/n] y Reload privilege tables now? [Y/n] y
But it gives me an error "Sorry you cannot use an empty password here" but in the screen i used to press the return key for the first question.
I stumbled upon this question but decided to run the queries manually through a Bash script:
#!/bin/bash # Make sure that NOBODY can access the server without a password mysql -e "UPDATE mysql.user SET Password = PASSWORD('CHANGEME') WHERE User = 'root'" # Kill the anonymous users mysql -e "DROP USER ''@'localhost'" # Because our hostname varies we'll use some Bash magic here. mysql -e "DROP USER ''@'$(hostname)'" # Kill off the demo database mysql -e "DROP DATABASE test" # Make our changes take effect mysql -e "FLUSH PRIVILEGES" # Any subsequent tries to run queries this way will get access denied because lack of usr/pwd param
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With