我正在尝试创建一个shell调用,用于在ubuntu 14.04上安装非交互式mysql 5.7社区服务器。根据使用debconf的各种来源,设置选择应该允许这样的安装,但我无法启动非交互式dpkg安装程序。
Bellow是我试图用于非交互式安装的env变量
vagrant@default-ubuntu-1404:/sql$ echo $DEBIAN_FRONTEND
noninteractive
vagrant@default-ubuntu-1404:/sql$ echo mysql-apt-config mysql-apt-config/enable-repo select mysql-5.7 | sudo debconf-set-selections
以下是系统的所有mysql-apt-config设置
vagrant@default-ubuntu-1404:/sql$ sudo debconf-get-selections | grep mysql
mysql-apt-config mysql-apt-config/select-tools select workbench-6.2 workbench-6.3 connector-python-2.0 connector-python-2.1 router-2.0 mysql-utilities-1.5 mysql-tools
mysql-apt-config mysql-apt-config/select-preview select
mysql-apt-config mysql-apt-config/repo-distro select ubuntu
mysql-apt-config mysql-apt-config/enable-repo select mysql-5.7
mysql-apt-config mysql-apt-config/repo-url string http://repo.mysql.com/apt/
# Choices: MySQL Server (Currently selected: mysql-5.7), MySQL Tools & Connectors (Currently selected: Enabled), MySQL Preview Packages (Currently selected: Disabled), Ok
mysql-apt-config mysql-apt-config/select-product select
mysql-apt-config mysql-apt-config/repo-codename select trusty
mysql-apt-config mysql-apt-config/unsupported-platform select abort
# Choices: mysql-5.6, mysql-5.7, None
mysql-apt-config mysql-apt-config/select-server select
安装本身:
wget http://dev.mysql.com/get/mysql-apt-config_0.7.2-1_all.deb
sudo dpkg -i mysql-apt-config_0.7.2-1_all.deb
以交互模式启动。
有什么想法吗?
如果以root
运行,这对我有效
export DEBIAN_FRONTEND=noninteractive
debconf-set-selections <<< 'mysql-apt-config mysql-apt-config/repo-codename select trusty'
debconf-set-selections <<< 'mysql-apt-config mysql-apt-config/repo-distro select ubuntu'
debconf-set-selections <<< 'mysql-apt-config mysql-apt-config/repo-url string http://repo.mysql.com/apt/'
debconf-set-selections <<< 'mysql-apt-config mysql-apt-config/select-preview select '
debconf-set-selections <<< 'mysql-apt-config mysql-apt-config/select-product select Ok'
debconf-set-selections <<< 'mysql-apt-config mysql-apt-config/select-server select mysql-5.7'
debconf-set-selections <<< 'mysql-apt-config mysql-apt-config/select-tools select '
debconf-set-selections <<< 'mysql-apt-config mysql-apt-config/unsupported-platform select abort'
wget http://dev.mysql.com/get/mysql-apt-config_0.7.2-1_all.deb
dpkg -i mysql-apt-config_0.7.2-1_all.deb
apt-get update
apt-get install -y mysql-server-5.7
接受的答案有效。我只想放一些链接,解释如何使用debconf-set-selections
和如何查找参数列表。
以非root用户身份运行时,导出的变量(DEBIAN_FRONTEND)不可用于sudo。使dpkg命令的可变部分对我有效。
sudo DEBIAN_FRONTEND=noninteractive dpkg -i mysql-apt-config_0.7.2-1_all.deb
只需运行即可。工作于16.04
export DEBIAN_FRONTEND=noninteractive
debconf-set-selections <<< 'mysql-server-5.7 mysql-server/root_password password password'
debconf-set-selections <<< 'mysql-server-5.7 mysql-server/root_password_again password password'
apt-get install --assume-yes mysql-server-5.7 mysql-client
#update 'password' to whatever you want to use
mysql -u root -password -e "use mysql; UPDATE user SET authentication_string=PASSWORD('password') WHERE User='root'; flush privileges;"