# Upgrading a Terraform-managed MySQL Flexible Server

Azure offers the option to [in-place upgrade](https://learn.microsoft.com/en-us/azure/mysql/flexible-server/how-to-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](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/mysql_flexible_server) - I wonder if we can just change the version number?

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1740761030117/40b91292-7591-4096-a378-0f3e33d6891e.png align="center")

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:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1740761186393/f1bec74e-43c6-4b87-af84-5347f37a97e7.png align="center")

Then, update the Terraform configuration:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1740762075706/908a3986-db42-4363-984d-098b3edfb88e.png align="center")

And the moment of truth - run `terraform plan`:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1740761248872/022ebafa-24e1-4d9e-a913-96738f65edb1.png align="center")

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:

```plaintext
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](https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-11.html) since MySQL version 8.0.11.
