I used RMySQL::dbWriteTable function in R to write a table (Spanish words) to MySQL on Windows, but I got the character '?' concerning some signals [ñ, í, á, ó, ú, ü, etc.].
I tried some solutions that I found on the internet, but those methods didn't work. Also, I used the Encoding function in R but was the same result in the three ways ( "UTF-8", "latin1" or "unknown")
That was my final code:
library(tidyverse) library(RMySQL) connection <- dbConnect(MySQL(), user = "data_xxxxx", host = "localhost", password = "xxxxxxxx", dbname = "data_xxxxx") dbSendQuery(connection, "SET NAMES utf8mb4;") dbSendQuery(connection, "SET CHARACTER SET utf8mb4;") dbSendQuery(connection, "SET character_set_connection=utf8mb4;") x = tibble(items = c('conrazón ñato', "íóúáñ'")) dbWriteTable(connection, 'prueba', x, overwrite = TRUE) prueba = dbReadTable(connection, 'prueba')
From PHP MySQL:
Server connection collation: utf8mb4_spanish_ci