我想要一个无需任何手动输入即可安装 MySQL 5.7 实例的 bash 脚本。
我正在关注数字海洋教程 https://www.digitalocean.com/community/tutorials/how-to-install-mysql-on-ubuntu-14-04它说对于 5.7,您必须运行以下命令,然后将命令放入提示符中(下面的屏幕截图)。
wget http://dev.mysql.com/get/mysql-apt-config_0.6.0-1_all.deb
sudo dpkg -i mysql-apt-config_0.6.0-1_all.deb
如果需要使用提示,我该如何自动化安装?我应该尝试模拟击键吗?或者我的处理方式是错误的?
这个答案是 Bimmy 和 khrm 答案的组合和修改。
STEP 1:
你必须设置debconf
值,将自动填充安装提示的值。
export DEBIAN_FRONTEND="noninteractive"
sudo debconf-set-selections <<< "mysql-server mysql-server/root_password password rootpw"
sudo debconf-set-selections <<< "mysql-server mysql-server/root_password_again password rootpw"
要获得您需要的值,只需正常运行安装即可,一个很好的教程是here https://serversforhackers.com/video/installing-mysql-with-debconf
STEP 2:
通过添加 5.7 存储库并更新 `apt-get 来更新 APT 所需的信息
sudo apt-key adv --keyserver pgp.mit.edu --recv-keys 5072E1F5
cat <<- EOF > /etc/apt/sources.list.d/mysql.list
deb http://repo.mysql.com/apt/ubuntu/ trusty mysql-5.7
EOF
sudo apt-get update
STEP 3:
安装MySQL。你可以运行我的mysql_secure_installation
但随后会要求您提供更多提示。mysql_secure_installation
只是一个脚本,因此如果您愿意,您可以只运行该脚本中与您相关的部分。
我刚刚跑了sudo apt-get install -y mysql-server-5.7
在其自己的。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)