diff --git a/mysql/resource_user.go b/mysql/resource_user.go index 7e0a6a05..f1aa5e22 100644 --- a/mysql/resource_user.go +++ b/mysql/resource_user.go @@ -181,17 +181,18 @@ func CreateUser(ctx context.Context, d *schema.ResourceData, meta interface{}) d return diag.Errorf("failed executing SQL: %v", err) } + user := fmt.Sprintf("%s@%s", d.Get("user").(string), d.Get("host").(string)) + d.SetId(user) + if updateStmtSql != "" { log.Println("Executing statement:", updateStmtSql) _, err = db.ExecContext(ctx, updateStmtSql) if err != nil { + d.Set("tls_option", "") return diag.Errorf("failed executing SQL: %v", err) } } - user := fmt.Sprintf("%s@%s", d.Get("user").(string), d.Get("host").(string)) - d.SetId(user) - return nil }