0

I've read a lot of posts on Stackoverflow and generally and they still do not seem to address my situation.

Running Laravel 7.x on PHP 7.4, I'm using Laravel-Excel to import into the db. Screenshot shows my database.php and table have the recommended utf8mb4 settings. Yet it complains of the column that has Chinese characters which when I replace with English, the import sails through. I am not doing a direct DB write here as Laravel-Excel does this with a call to Excel::import in my controller.

Is there some other step I can take?

SHOW CREATE TABLE ends with:

ENGINE=INNODB AUTO_INCREMENT=15735 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin

SHOW VARIABLES LIKE 'char%' gives:

"Variable_name" "Value"
"character_set_client"  "utf8"
"character_set_connection"  "utf8"
"character_set_database"    "utf8mb4"
"character_set_filesystem"  "binary"
"character_set_results" "utf8"
"character_set_server"  "latin1"
"character_set_system"  "utf8"
"character_sets_dir"    "C:\\xampp\\mysql\\share\\charsets\\"

enter image description here

user1729972
  • 712
  • 2
  • 9
  • 29
  • Please provide `SHOW CREATE TABLE` and `SHOW VARIABLES LIKE 'char%';` _as text_. Also diagnose the particular type of problem with the help of https://stackoverflow.com/questions/38363566/trouble-with-utf8-characters-what-i-see-is-not-what-i-stored – Rick James Aug 25 '20 at 18:28

1 Answers1

1

The following db/ table changes:

ALTER DATABASE <mydb> CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci;
ALTER TABLE <mytable> CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci;

and changes in database.php:

...
'collation' => 'utf8mb4_unicode_520_ci',
...    

Resolved the problem for me. php.ini already had the right setting.

Thanks @RickJames

user1729972
  • 712
  • 2
  • 9
  • 29