I recently upgraded the ODBC driver that I am using to connect to an AWS RDS MySQL DB in RStudio. I upgraded to the mysql-connector-odbc-9.1.0 from 8.4. After doing so RStudio exits with a fatal error as soon as the code attempts to connect via ODBC to the database.
"R Session Aborted
R encountered a fata error
The session was terminated"
In a standalone R session outside of RStudio the issue does not occur so I lean towards an issue affecting RStudio only.
If I revert back to any of the 8.x versions the issue goes away and everything works as expected. I am using R version 4.4.0 and RStudio 2024.09.0 Build 375. Windows Server 2022 operating system which is up to date with updates.
Confirming same issue, Rstudio 2024.09.1+394 with R 4.2.2, connection works fine in base R but R session in Rstudio crashes upon calling odbcConnect(). Same on a colleague's system. Issue does not occur with mysql connector/odbc 9.0.0.
They recommend updating VC++ to version 14.40. Apparently this has worked for a number of folks. It did not work for me and the R issue we are having but could be worth a shot if you want it.
Thanks for the link, afraid this didn't work on my machine either.
Right now I'm using version 9.0.0 from the archives at mysql.com, which works normally.
After waiting out the release of 9.0.2 and finding that it still caused RStudio to crash I did some further digging and found the issue.
Technically, it is the same issue with VC++ versions below 14.40 but...
RStudio includes copies of VC++ msvcp140***.dll files within its \bin directory. Instead of reaching out to the system level .dlls for Visual C++, it uses its own copies. The .dll files installed with even the current version of RStudio are not up to date (version 14.29). A bug in the >9.0.0 ODBC driver will crash the R session when using these older files
Reinstalling the latest version of RStudio does not replace these out of date files. Updating VC++ does not affect the RStudio copies.
Resolution:
Update Visual C++ 2015-2022 Redistributable (x64) to at least version 14.40.* (technically I have only tested with version 14.42.34433.0)
Copy these 5 files from C:\Windows\System32
msvcp140.dll
msvcp140_1.dll
msvcp140_2.dll
msvcp140_atomic_wait.dll
msvcp140_codecvt_ids.dll
Paste the copied files into to C:\Program Files \RStudio\resources\app\bin and OVERWRITE the 5 that are already in there.
This should fix the problem and allow you to use the newest MySQL ODBC Connector versions available.
I am sure RStudio will update the packaged .dlls at some point so the other option is to wait for an update.