Oracle’s website shows End of life for MySQL 5.5 as of Jan 20th of 2019, so hurry up and upgrade!
I am working building some demos for Cloud SQL and one of the requirements I had was to run MySQL 5.7 and WordPress as my sample application. The demo consisted on migrating from a single VM environment with WordPress and MySQL running alongside. The narrative: the site got popular and the database became the bottle neck because of all the shared resources between them and the application. The proposed solution? A minimal downtime migration to Cloud SQL, moving the data layer to a dedicated server.
I am going to be doing this demo a lot of times, so I needed some way to automate it. I thought of doing through Docker. I am not Docker proficient, and to begin with I asked Anthony for help to get me to what I wanted, but there are so many nuances! Maybe someone will find a better solution to it than this one, but I decided to share what I got.
Let’s examine the two scenarios I faced. All examples assume Debian/Ubuntu.
I don’t run Docker, just have a VM and want to have MySQL 5.7
In this case it’s straightforward: you need to use the MySQL official APT repository available in https://dev.mysql.com/downloads/repo/apt/.
At this time the most recent version is
mysql-apt-config_0.8.12-1_all.deb, keep an eye before continuing this because it may change the version until you use this tutorial.
|sudo wget -O /tmp/mysql.deb https://dev.mysql.com/get/mysql-apt-config_0.8.12-1_all.deb|
|echo mysql-apt-config mysql-apt-config/select-server select mysql-5.7 | sudo debconf-set-selections|
|echo mysql-community-server mysql-community-server/root-pass password $DB_ROOT_PASSWORD | sudo debconf-set-selections|
|echo mysql-community-server mysql-community-server/re-root-pass password $DB_ROOT_PASSWORD | sudo debconf-set-selections|
|sudo DEBIAN_FRONTEND=noninteractive dpkg -i /tmp/mysql.deb|
|sudo apt-get update|
|sudo apt-get -y install mysql-server mysql-client|
In line 2 you can change from
mysql-8.0, if unspecified the command, version 8.0 will be installed.
I run Docker and want to have 5.7 or 8.0 installed on it
It’s a bit similar to the previous situation, you still need to go to the APT repository page to know which file to download and add this on your
|### WHATEVER COMES BEFORE ###|
|EXPOSE 80 443 3306|
|ENV DEBIAN_FRONTEND noninteractive|
|RUN apt-get update|
|RUN apt-get -y install wget lsb-release gnupg|
|RUN curl -o /tmp/mysql.deb https://dev.mysql.com/get/mysql-apt-config_0.8.12-1_all.deb|
|RUN echo mysql-apt-config mysql-apt-config/select-server select mysql-5.7 | debconf-set-selections|
|RUN echo mysql-community-server mysql-community-server/root-pass $DB_ROOT_PASSWORD rot | debconf-set-selections|
|RUN echo mysql-community-server mysql-community-server/re-root-pass $DB_ROOT_PASSWORD rot | debconf-set-selections|
|RUN dpkg -i /tmp/mysql.deb|
|RUN apt-get update|
|RUN apt-get -y install mysql-server mysql-client|
|### WHATEVER COMES AFTER ###|
Notice, you can also change the version of MySQL here. Don’t forget to pass
DB_ROOT_PASSWORD when doing your
docker build using the
--build-arg argument. More details here.
These are the workarounds to avoid using MySQL 5.5. After that I was able to finally automate my demo. Feel free here to share better examples of what I did, as I said, I don’t have proficiency in the subject.