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'
sudo apt-get -y install mysql-server
对于特定的版本(例如)mysql-server-5.6
,您需要这样指定版本:
sudo debconf-set-selections <<< 'mysql-server-5.6 mysql-server/root_password password your_password'
sudo debconf-set-selections <<< 'mysql-server-5.6 mysql-server/root_password_again password your_password'
sudo apt-get -y install mysql-server-5.6
对于mysql-community-server,密钥略有不同:
sudo debconf-set-selections <<< 'mysql-community-server mysql-community-server/root-pass password your_password'
sudo debconf-set-selections <<< 'mysql-community-server mysql-community-server/re-root-pass password your_password'
sudo apt-get -y install mysql-community-server
将your_password替换为所需的根密码。(似乎your_password也可以留空以获取空白的root密码。)
如果您的外壳不支持此处字符串(zsh,ksh93和bash支持它们),请使用:
echo ... | sudo debconf-set-selections