RDS MySQL 5.7 and Entity Framework - mysql

I just upgraded to the latest MySQL RDS version, from 5.6.
Since we're still using some .NET based on Entity Framework Database First, we cannot run "Update" on the model.
This is a known issue in MySQL 5.7.
A way to fix this, is to run the following on the database:
set global optimizer_switch='derived_merge=OFF'
But, when I do so, I get the usual error about missing SUPER privilege.
I've already added "trust_creators" to my parameters group, and rebooted the instance.
What to do?

The optimizer_switch system variable -- like all configurable system variables -- is configured in the RDS Parameter Group.

Related

Table isn't found due to case-sensitivity MySQL query using .NET MySQL Connector

I am using an old website that I've created using .NET 4.0 with XSD (Table Adapters). I've migrated my database from MySQL 5.4 to MySQL 5.7 on AWS RDS.
The problem that I have is that when I run the website, it can't find the table because in some of the queries it searches for a table with a capital letters in the beginning. If I change the table name to with capital letter, it finds it. It's an old project, and I prefer not messing around with the old code.
I use .NET MySQL Connector.
show variables where Variable_name='lower_case_table_names'
The above returns '0' which means 'lettercase specified in the CREATE TABLE or CREATE DATABASE statement. Name comparisons are case sensitive.'
Is there a way to update the web.config or do something in the MySQL database to make it work so the query will count as case insensitive?
Try with like
where Variable_name like 'lower_case_table_names
The MySQL 5.7 on RDS has not value for the lower_case_table_names in the GROUP PARAMETERS in RDS configuration panel. Once I set it to 1 and rebooted the server, my old .NET website worked properly.

How can I get 'max_statement_time' as a global variable in a GCP Cloud Sql mysql 5.6 instance?

As of mysql version 5.7.8, the variable max_statement_time was renamed to max_execution_time. I have an application that checks the database version and sets the correct variable according to that version number.
When I configure my application to use a local mysql installation, everything is fine, but when I configure it to use Google Cloud Sql, it works on 5.7, but fails on 5.6. The error it gives is:
java.sql.SQLException: Unknown system variable 'max_statement_time'
From a mysql shell I ran show variables like 'max%time' and got these results:
mysql 5.7 via percona: max_execution_time
mysql 5.7 via google max_execution_time
mysql 5.6 via percona max_statement_time
mysql 5.6 via google [empty]
I see that google has documentation about these flags here but max_statement_time doesn't appear in the list. Is there something I can do to force that flag to appear so that my application can set it an proceed happily?
Cloud SQL is a Google managed service. You do not have access to change all the mysql flags freely. Here there is the list of flags that you can see/ modify. If max_statement_time is not in that list it you cannot do anything related to it.
My recommendation is to use max_execution_time flag instead of max_statement_time. As it is mentioned in the documentation:
For a given flag, Cloud SQL might support a different range than the corresponding MySQL parameter or option.
The flags/ limations are not the same for CloudSQL with a simple MySQL database.

Prevent concurrency violation in MySQL and Devart MySQL Connector

I have inherited support for an application used by a number of charities.
The application uses an Access database for local storage and has a web based interface with a MySQL database.
The application syncs data to the MySQL database using a Devart MySQL connector but this is constantly giving the following error:
Concurrency violation: the Update Command affected 0 of the expected 1 records.
I've checked and I think this is due to a setting in Devart Found records but as I can't recompile the application I don't think there's a way to fix it from that side.
Are there any changes I can make from the database side to prevent these errors?
Setting "FoundRows=true;" in the connection string is the only way to change the provider behavior. Please check your application, maybe it allows modifying the connection string via its *.config file?

Is it possible to downgrade a AWS RDS from mysql 5.7 to lower version (say 5.6)

This is something i need to figure out, my company runs a number of prod RDS on AWS. Some of the mysql RDS run with 5.7 , i need to downgrade the mysql to 5.6 or 5.5 . Is this functionality provided by AWS.
Scenario: A mysql server already up and running with mysql version 5.7, Downgrade this to 5.6
-> If this is possible then what are the possible ways ?
-> How to do this ?
This is not something that AWS provides out of the box, however it can be solved with below 2 approaches depending on your database size and downtime that you can accept.
It might worth considering fixing application compatibility instead of downgrading DB which is more risky operation.
1. Dump, restore and switch method
Dump your currently running database with mysqldump utility. Start a new RDS instance with downgraded engine, load your dumped data into it. Switch your application to use RDS instance with downgraded engine.
2. Dump, restore, replicate & switch method
Dump your currently running database with mysqldump utility. Start a new RDS instance with downgraded MySQL engine, load your dumped data into it.
Set the new, downgraded DB instance as read replica of your old DB instance using mysql.rds_set_external_master and then start replication using mysql.rds_start_replication. Stop writes to your original DB, once the read replica catches up (you must monitor replication lag), run mysql.rds_reset_external_master which will promote your downgraded instance and turn off replication. Point your application to the downgraded RDS DB instance.
Method 2 will shorten your downtime to minimum, but is a bit more complex to execute. Here is a command reference to get familiar with to help you succeed: MySQL on Amazon RDS SQL Reference
You will find a great amount of examples in RDS documentation also - Importing and Exporting Data From a MySQL DB Instance:

db connection initiated multiple times by rails app

Connecting to database specified by database.yml is called multiple times by my rails app, even when the MySQL RDS db instance is up and running. How do I debug this issue?
Which version of Rails? Which version of the MySQL gem? (You can check the versions in Gemfile.lock, or with bundle show).
In database.yml, there's also a pool parameter which specifies how many DB connections should be made (to accomodate multiple threads using the same database). By default, this is at 5.