错误:R无法连接到MySQL

时间:2018-04-27 01:28:11

标签: mysql r rmysql

我昨天将MySQL更新到最新版本8.0.11并尝试使用RMySQL连接到MySQL,但它无法正常工作,我找不到任何解决方案。

我的代码:

library(RMySQL) 
con <- dbConnect(MySQL(), user="hello", password="hi", dbname = "webscrape", host="xx.xxx.xxx.xxx", port=xxxx)

错误:

Error in .local(drv, ...) : 
  Failed to connect to database: Error: Can't initialize character set unknown (path: compiled_in)

5 个答案:

答案 0 :(得分:3)

我这样解决了这个问题:

用户Windows

1。.local(drv,...)中的错误:     无法连接到数据库:错误:无法初始化未知的字符集(路径:Compiled_in)

添加以下行之后:

文件路径:%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-无法加载身份验证插件“ caching_sha2_password”

    ALTER USER 'yourusername'@'localhost' IDENTIFIED WITH mysql_native_password BY 'youpassword';

参考文献:

MySQL my.ini location

Change MySQL default character set to UTF-8 in my.cnf?

Authentication plugin 'caching_sha2_password' cannot be loaded

答案 1 :(得分:1)

有同样的问题。尝试更改架构上的字符集。还尝试使用遗留身份验证方法选项重新安装MySQL,但仍然没有运气RMySQL。

尝试了RMariaDB包,它运行良好。我会切换到RMariaDB而不是降级MySQL。

https://cran.r-project.org/web/packages/RMariaDB/

答案 2 :(得分:1)

我也遇到了这个问题,并且在最近发布的MySQL 5.8中注意到,服务器和客户端连接的默认字符集现在默认设置为utf8mb4。在MySQL 5.7中,默认字符集设置为utf8。

我尝试使用服务器和客户端的字符集,将值恢复为utf8,但由于无法正常工作,因此将已安装的MySql恢复为5.7。 之后,RMySQL开始工作。

感觉RMySQL目前无法支持utf8mb4,需要进行更新。

答案 3 :(得分:0)

有关此问题,可以在此post上找到一种解决方案,可以防止您更改R首选库和/或降级MySQL。

您只需要更改my.cnf设置。

答案 4 :(得分:0)

我具有相同的Pb:

 Service.Tasks.List(list.Id).ShowCompleted = true; 
 var tasks = await Service.Tasks.List(list.Id).ExecuteAsync();

我尝试了Hugo(修改my.ini),David Guerin(使用RMariaDB)的解决方案,但两者均无法正常工作。经过研究和经验后,此解决方案对我有用

修改my.ini(这是找到Error in .local(drv, ...) : Failed to connect to database: Error: Can't initialize character set unknown (path: compiled_in) 的路径):

与雨果的答案相反,您需要放置utf8mb4(utf8不是一个好东西)

[客户]

C:\ProgramData\MySQL\MySQL Server 8.0

[mysql]

default-character-set = utf8 (the old line "utf" to "utfmb4")
default-character-set = utf8mb4 (the new line with modification)

[mysqld]

default-character-set = utf8 (the old line "utf" to "utfmb4")
default-character-set = utf8mb4 (the new line with modification)

在mysql中,您需要更改密码:

character-set-client-handshake = FALSE  (new line to add)
character-set-server = utf8mb4  (the old line "utf" to "utfmb4")        
collation-server = utf8mb4_unicode_ci   (new line to add)
skip-character-set-client-handshake (Line to remove)