My OS is CentOS 6.6 and I want to know how to install mysql-server automatically via shell script.
I have found that there is a topic talked about the same issue but it failed on CentOS 6: install mysql on ubuntu without password prompt
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password your_password'
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password your_password'
The error message is
bash: debconf-set-selections: command not found
Here is my basic script
#!/bin/sh
# Make sure only root can run our script
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
#password setting
root_password='abc123'
#install mysql-server
yum install mysql mysql-server
#start service
service mysqld start
#MySQL Initial Setup
mysql_secure_installation
#This command needs root password and answers(y/n) for secure questions
Does there have any methods to automatically fill the root password and answer 'y' to most of the secure question.
Or it have alternative way to achieve the same thing. That is, a script to install myaql-server automatically and without password prompt.
very appreciated for your help.