AWS Ubuntu 14.04上无人值守的MySQL安装

时间:2015-06-30 17:07:33

标签: mysql bash ubuntu amazon-web-services

我试图执行以下脚本来安装无人值守的MySQL。

" export DEBIAN_FRONTEND = noninteractive"没有工作 - 我仍然需要按几次输入以通过提示。

AWS镜像:Ubuntu Server 14.04 LTS(PV),SSD卷类型 - ami-d85e75b0

有什么建议吗?

#!/bin/sh

sudo apt-get install libaio1

export DEBIAN_FRONTEND=noninteractive

# Install script for mysql database

sudo groupadd mysql
sudo useradd -r -g mysql mysql
sudo tar xvf mysql-server_5.6.21-1ubuntu12.04_amd64.deb-bundle.tar
if [ $? != 0 ];then echo "Unable to extract tar file."; exit 100; fi

sudo dpkg -i mysql-common_5.6.21-1ubuntu12.04_amd64.deb
if [ $? != 0 ];then echo "Unable to install package mysql-common."; exit 100; fi

sudo dpkg -i mysql-community-server_5.6.21-1ubuntu12.04_amd64.deb
if [ $? != 0 ];then echo "Unable to install package mysql-community-server."; exit 100; fi

sudo dpkg -i mysql-community-client_5.6.21-1ubuntu12.04_amd64.deb
if [ $? != 0 ];then echo "Unable to install package mysql-community-client."; exit 100; fi

sudo mv /etc/mysql/my.cnf my.cnf.in
if [ $? != 0 ];then echo "Unable to move /etc/mysql/my.cnf."; exit 100; fi

sudo sed -e s/127.0.0.1/0.0.0.0/g my.cnf.in | sudo tee /etc/mysql/my.cnf
if [ $? != 0 ];then echo "Unable to configure my.cnf."; exit 100; fi

#sudo rm -f my.cnf.in

sudo /etc/init.d/mysql restart
if [ $? != 0 ];then echo "Unable to restart mysql server."; exit 100; fi

exit 0

# Leave the last line empty, otherwise it can cause problems running the script

2 个答案:

答案 0 :(得分:0)

问候我还没试过,但几周前我看到了这个啧啧:

https://serversforhackers.com/video/installing-mysql-with-debconf

答案 1 :(得分:0)

请注意,在手动man dpkg中,您可以找到一组选项--force-confdef(强制保留默认选项而不提示)和--force-confold(强制保留旧的配置文件)

所以,最终命令看起来像(取决于你需要什么):
sudo dpkg -i --force-confdef mysql-common_5.6.21-1ubuntu12.04_amd64.deb

sudo dpkg -i --force-confold mysql-common_5.6.21-1ubuntu12.04_amd64.deb

试试这种方式,它帮助我issue here。 顺便问一下,dpkg问你什么?