I updated MySQL to latest version 8.0.11 yesterday and tried to use RMySQL to connect to MySQL, but it was not working and I could not find any solution.
My code:
library(RMySQL)
con <- dbConnect(MySQL(), user="hello", password="hi", dbname = "webscrape", host="xx.xxx.xxx.xxx", port=xxxx)
Error:
Error in .local(drv, ...) :
Failed to connect to database: Error: Can't initialize character set unknown (path: compiled_in)
normally means that there is no MySQL server running on the system or that you are using an incorrect Unix socket file name or TCP/IP port number when trying to connect to the server. You should also check that the TCP/IP port you are using has not been blocked by a firewall or port blocking service.
We will use a database called MySQL to store data. R can perform analysis and data storage without the use of a relational database. However, there are times when databases are very useful including: Placing the results of an R script on a web site where the data can be interacted with.
The MySQL server has gone away error, means that MySQL server (mysqld) timed out and closed the connection. By default, MySQL will close connections after eight hours (28800 seconds) if nothing happens.
I solved this problem like this:
User Windows
1.Error in .local(drv, ...) : Failed to connect to database: Error: Can't initialize character set unknown (path: compiled_in)
After adding these lines:
file path: %PROGRAMDATA%\MySQL\MySQL Server X.X\my.ini
[mysqld]
collation-server = utf8_unicode_ci
init-connect='SET NAMES utf8'
character-set-server = utf8
skip-character-set-client-handshake
[client]
default-character-set = utf8
[mysql]
default-character-set = utf8
2- Authentication plugin 'caching_sha2_password' cannot be loaded
ALTER USER 'yourusername'@'localhost' IDENTIFIED WITH mysql_native_password BY 'youpassword';
References:
MySQL my.ini location
Change MySQL default character set to UTF-8 in my.cnf?
Authentication plugin 'caching_sha2_password' cannot be loaded
Had the same problem. Tried changing character sets on the schema. Also tried reinstalling MySQL with the legacy authentication method option and still no luck with RMySQL.
Tried RMariaDB package and it worked. I would switch to RMariaDB rather than downgrading MySQL.
https://cran.r-project.org/web/packages/RMariaDB/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With