laravel 解决保存Emoji 表情问题

ALTER DATABASE database_name CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
ALTER TABLE table_name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE table_name CHANGE column_name VARCHAR(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

1、更改字符编码、

2、修改laravel配置

'mysql'  => [
            'driver'    => 'mysql',
            'host'      => env('DB_HOST', 'localhost'),
            'port'      => env('DB_PORT', '3306'),'charset'   => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix'    => 'yueke_',
            'strict'    => true,
            'engine'    => null,
        ],

 

posted @ 2019-02-23 22:29  MvloveYouForever  阅读(306)  评论(0编辑  收藏  举报