Last active
July 1, 2020 10:13
-
-
Save fideloper/e774cb62d8be28da8a93 to your computer and use it in GitHub Desktop.
instal mysql5.7 non-interactive on ubuntu 14.04
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# This is assumed to be run as root or with sudo | |
export DEBIAN_FRONTEND=noninteractive | |
# Import MySQL 5.7 Key | |
# gpg: key 5072E1F5: public key "MySQL Release Engineering <[email protected]>" imported | |
apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys 5072E1F5 | |
echo "deb http://repo.mysql.com/apt/ubuntu/ trusty mysql-5.7" | tee -a /etc/apt/sources.list.d/mysql.list | |
apt-get update | |
# Install MySQL | |
MYSQL_PASS="secret" | |
debconf-set-selections <<< "mysql-community-server mysql-community-server/data-dir select ''" | |
debconf-set-selections <<< "mysql-community-server mysql-community-server/root-pass password $MYSQL_PASS" | |
debconf-set-selections <<< "mysql-community-server mysql-community-server/re-root-pass password $MYSQL_PASS" | |
apt-get install -y mysql-server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
# Example tasks/main.yml file of a mysql ansible role, which should install mysql 5.7 | |
# The apt_key id may need changing, I'm not sure | |
- name: Add MySQL Apt Key | |
apt_key: | |
keyserver: ha.pool.sks-keyservers.net | |
id: A4A9406876FCBD3C456770C88C718D3B5072E1F5 | |
state: present | |
- name: Add MySQL Repository | |
copy: | |
src: mysql.list # This is files/mysql.list, which just contains "deb http://repo.mysql.com/apt/ubuntu/ trusty mysql-5.7" | |
dest: /etc/apt/sources.list.d/mysql.list | |
owner: root | |
group: root | |
- name: Set root Password | |
debconf: | |
name: mysql-community-server | |
question: 'mysql-community-server/root-pass' | |
value: '{{ root_pass }}' # Set as a variable | |
vtype: password | |
- name: Set root Password Again | |
debconf: | |
name: mysql-community-server | |
question: 'mysql-community-server/re-root-pass' | |
value: '{{ root_pass }}' # Set as a variable | |
vtype: password | |
- name: Install MySQL 5.7 | |
apt: | |
pkg: '{{ item }}' | |
state: latest | |
update_cache: true | |
with_items: | |
- mysql-server | |
notify: | |
- Start MySQL |
Protopopys
commented
Jan 19, 2018
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment