Home:ALL Converter>Mysql automated installation stuck

Mysql automated installation stuck

Ask Time:2017-07-28T09:34:17         Author:surendar

Json Formatter

I have written a script to install some set of packages to a list of servers. When i execute the script mysql installation got stuck at "enter the root password" section. Is there anything i need to modify in my script ? Advice me.

Is there any way to pass the mysql root password through the script itself ?

Below is the code which i used

#!/usr/bin/env bash
read -p "Enter server name : " servername
echo "Installing package on $servername"
ssh "${servername}" sudo apt-get -y install apache2 mysql-server

Installation got stuck here

Even if I enter the password, it wouldn't proceed to the next step. I am very beginner for scripting. Let me know where to modify the script.

Author:surendar,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/45363503/mysql-automated-installation-stuck
marekful :

apt-get is a front-end to dpkg and debconf and is running in interactive mode by default, even -y won't change that.\n\nmysql-server installation requires the root password to be interactively entered during installation. \n\nTo fully automatically install MySQL server on a Debian based Linux distro, you can enter non-interactive mode and preset the MySQL root password as follows.\n\nIn the shell where you want to run the process, execute:\n\nexport DEBIAN_FRONTEND=\"noninteractive\"\n\n\nThen\n\napt-get install -y debconf-utils\ndebconf-set-selections <<< \"mysql-server mysql-server/root_password yournewpassword\"\ndebconf-set-selections <<< \"mysql-server mysql-server/root_password_again yournewpassword\"\napt-get install -y mysql-server-5.6\n",
2017-07-28T01:41:39
yy