完全从Ubuntu上的bash脚本安装mysql 5.7 [英] install mysql 5.7 purely from bash script on Ubuntu
问题描述
我想要一个不需要任何手动输入即可安装MySQL 5.7实例的bash脚本.
I want a bash script that installs a MySQL 5.7 instance without needing any manual input.
我正在关注教程在Digital Ocean上,它说到5.7,您必须运行以下命令,然后将命令放入提示符(下面的屏幕截图).
I was following the tutorial on Digital Ocean and it says for 5.7 you have to run the following commands and then put commands into a prompt (screenshot below).
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
如果要求我使用提示,如何自动执行安装?我应该尝试模拟按键吗?还是我走错路了?
How can I automate the installation if it requires me to use a prompt? Should I try to simulate keystrokes? Or am I going about it the wrong way?
推荐答案
此答案是Bimmy和khrm答案的组合和变更.
This answer is a combination and alteration of Bimmy's and khrm's answers.
步骤1:
您必须设置debconf
值,这些值将自动填写安装提示的值.
You have to set debconf
values which will automatically fill in the values prompted for by the installation.
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"
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"
要获取所需的值,只需正常运行安装即可,它的一个很好的教程是这里
To get the values you need, just run installation normally, a good tutorial of it is here
第2步:
通过添加5.7存储库并更新`apt-get
Update the information needed for APT by adding the 5.7 repository and updating `apt-get
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
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
步骤3:
安装MySQL.您可以运行我的mysql_secure_installation
,但随后会要求您提供更多提示. mysql_secure_installation
只是一个脚本,因此如果您愿意,可以只运行该脚本中与您相关的部分.
Install MySQL. You can run my mysql_secure_installation
but then that will ask you for more prompts. mysql_secure_installation
is just a script so if you want to you can just run the parts of that script which are relevant to you.
我刚跑了
sudo apt-get install -y mysql-server-5.7
本身.
这篇关于完全从Ubuntu上的bash脚本安装mysql 5.7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!