Skip to content

Instantly share code, notes, and snippets.

@mahemoff
Created April 13, 2015 14:49
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mahemoff/54b31e272421472d4fb6 to your computer and use it in GitHub Desktop.
Save mahemoff/54b31e272421472d4fb6 to your computer and use it in GitHub Desktop.
MySQL 5.6 in CircleCI
dependencies:
post:
- export DEBIAN_FRONTEND=noninteractive
- sudo apt-get -y remove mysql-server
- sudo apt-get -y autoremove
- sudo apt-get -y install software-properties-common
- sudo add-apt-repository -y ppa:ondrej/mysql-5.6
- sudo apt-get update
- sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password ""'
- sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password ""'
- sudo apt-get -y install mysql-server
@mahemoff
Copy link
Author

Background: I migrated to millisecond-precision timestamps which broke Circle. Upgrading to Maria on Circle proved to be a pain due to this MySQL gem problem so I compromised with MySQL 5.6 upgrade as above. Fortunately the gem works seamlessly.

@scosman
Copy link

scosman commented Jul 7, 2015

CircleCI also has official instructions here: https://circleci.com/docs/faq#how-do-i-use-mysql-5-6

@kenden
Copy link

kenden commented Apr 13, 2016

I replaced
sudo add-apt-repository -y ppa:ondrej/mysql-5.6
by
sudo apt-add-repository -y 'deb http://ppa.launchpad.net/ondrej/mysql-experimental/ubuntu precise main'
and reformatted to:

dependencies:
  pre:
    # installing mysql 5.6 (5.5 is installed by default)
    - >
      export DEBIAN_FRONTEND=noninteractive
      && sudo apt-get -y remove mysql-server && sudo apt-get -y autoremove
      && sudo apt-get -y install software-properties-common
      && sudo apt-add-repository -y 'deb http://ppa.launchpad.net/ondrej/mysql-experimental/ubuntu precise main'
      && sudo apt-get update
      && sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password ""'
      && sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password ""'
      && sudo apt-get -y install mysql-server

to avoid having many steps in circleci.

@frenchie4111
Copy link

Running this in CircleCI adds atleast 40 seconds to my build times, does anyone know of a way to cache this install?

@jfeldstein
Copy link

I've asked their support. They don't have a way.

@eexit
Copy link

eexit commented Feb 9, 2017

Hi there,

The code above didn't work because apt would get a bunch of 404 errors.
This worked for me:

machine:
  pre:
    # Install MySQL 5.6 (5.5 is installed by default)
    - >
      export DEBIAN_FRONTEND=noninteractive
      && sudo apt-get update -y; true
      && sudo apt-get -y remove mysql-server
      && sudo apt-get -y autoremove
      && sudo apt-get -y install software-properties-common
      && sudo apt-add-repository -y 'deb http://ppa.launchpad.net/ondrej/mysql-experimental/ubuntu precise main'
      && sudo apt-get update -y; true
      && sudo apt-get -y install mysql-server
      && sudo chown -R mysql:mysql /var/lib/mysql

@ccopto
Copy link

ccopto commented Jun 12, 2017

Hi all,

I took the code from @eexit and change a couple of lines because it wasn't working on my builds, here is my successful attempt, hope it helps.

machine:
    pre:
    - sudo apt-get update -y; true
    - sudo apt-get -y remove mysql-server
    - sudo apt-get -y install software-properties-common
    - sudo apt-add-repository -y 'deb http://ppa.launchpad.net/ondrej/mysql-experimental/ubuntu precise main'
    - sudo apt-get update -y; true
    - export DEBIAN_FRONTEND=noninteractive && sudo -E apt-get -y install mysql-server
    - sudo chown -R mysql:mysql /var/lib/mysql

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment