How to configure the MySQL APT repo on Ubuntu, on a non-interactive shell

debconfdpkgMySQL

I want to install MySQL 5.7 on Travis CI, which runs Ubuntu 12 virtual machines.

I'm willing to use the official MySQL APT repo:

wget http://dev.mysql.com/get/mysql-apt-config_0.2.1-1ubuntu12.04_all.deb
sudo dpkg --install mysql-apt-config_0.2.1-1ubuntu12.04_all.deb

But the problem is, installing this package opens an interactive menu asking the following question:

Which Server version do you wish to receive?  
    - mysql-5.6  
    - mysql-5.7-dmr

As the installation is part of an automated script, I'm not behind the terminal to answer the question. The only thing I can find in the doc is:

Selecting a Major Release Version

By default, all installations and upgrades for your MySQL server and the other required components come from the release series of the major version you have selected during the installation of the configuration package (see Adding the MySQL APT Repository). However, you can switch to another supported major release series at any time by reconfiguring the configuration package you have installed. Use the following command:

shell> sudo dpkg-reconfigure mysql-apt-config

But again, this opens an interactive menu.

How to install this APT repository and configure it to use mysql-5.7-dmr, on a non-interactive shell?

Best Answer

Courtesy @hbdgaf, this how-to put me on the right track:

export DEBIAN_FRONTEND=noninteractive
echo mysql-apt-config mysql-apt-config/enable-repo select mysql-5.7-dmr | sudo debconf-set-selections
wget http://dev.mysql.com/get/mysql-apt-config_0.2.1-1ubuntu12.04_all.deb
sudo dpkg --install mysql-apt-config_0.2.1-1ubuntu12.04_all.deb

I put together this gist for the whole process.

Related Question