Upgrading a Terraform-managed MySQL Flexible Server

Geoff LeeGeoff Lee
1 min read

Azure offers the option to in-place upgrade an instance of Azure Database for MySQL Flexible Server (its managed MySQL-as-a-Service offering) from major version 5 to 8. Pretty handy. My MySQL flexible server is managed by Terraform - I wonder if we can just change the version number?

Ah.

Ok, what happens if I run the upgrade using the Azure portal (or CLI) and then change the version number in the Terraform config? Let’s find out.

Deploy the upgrade:

Then, update the Terraform configuration:

And the moment of truth - run terraform plan:

We’re in business!

As a side note, this MySQL server was in almost completely stock configuration but still produced an error when validating the upgrade:

Find invalid server parameters, please correct before upgrade to new server version
Name: sql_mode, 
Current value: ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER, 
Allowed values: ,ALLOW_INVALID_DATES,ANSI_QUOTES,ERROR_FOR_DIVISION_BY_ZERO,HIGH_NOT_PRECEDENCE,IGNORE_SPACE,NO_AUTO_VALUE_ON_ZERO,NO_BACKSLASH_ESCAPES,NO_DIR_IN_CREATE,NO_ENGINE_SUBSTITUTION,NO_UNSIGNED_SUBTRACTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ONLY_FULL_GROUP_BY,PAD_CHAR_TO_FULL_LENGTH,PIPES_AS_CONCAT,REAL_AS_FLOAT,STRICT_ALL_TABLES,STRICT_TRANS_TABLES,TIME_TRUNCATE_FRACTIONAL, 
Issueed values: NO_AUTO_CREATE_USER

Fixing this was a matter of changing the sql_mode setting in the ‘Server Parameters’ pane to remove NO_AUTO_CREATE_USER which has been removed since MySQL version 8.0.11.

0
Subscribe to my newsletter

Read articles from Geoff Lee directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Geoff Lee
Geoff Lee