从fastadmin旧版本升级之后,数据库表字符集需要转换成utf8mb4,否则,如果使用微信登录,会员的微信昵称包含emoji,登录的时候就会报错。
这里有个简单脚本,可以生成转换utf8mb4所需的SQL:(把yourDbName替换成数据库名称)
use information_schema;SELECT concat("ALTER DATABASE `",table_schema,"` CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;") as _sql FROM `TABLES` where table_schema like "yourDbName" and TABLE_TYPE='BASE TABLE' group by table_schema;SELECT concat("ALTER TABLE `",table_schema,"`.`",table_name,"` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;") as _sql FROM `TABLES` where table_schema like "yourDbName" and TABLE_TYPE='BASE TABLE' group by table_schema, table_name;SELECT concat("ALTER TABLE `",table_schema,"`.`",table_name, "` CHANGE `",column_name,"` `",column_name,"` ",data_type,"(",character_maximum_length,") CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci",IF(is_nullable="YES"," NULL"," NOT NULL"),";") as _sql FROM `COLUMNS` where table_schema like "yourDbName" and data_type in ('varchar','char');
把生成的SQL再执行一下即可,以上脚本在10.4.12-MariaDB下测试通过。
希望以上内容对你有所帮助!如果还有其他问题,请随时提问。 各类知识收集 拥有多年CMS企业建站经验,对 iCMS, Fastadmin, ClassCMS, LeCMS, PbootCMS, PHPCMS, 易优CMS, YzmCMS, 讯睿CMS, 极致CMS, Wordpress, HkCMS, YznCMS, WellCMS, ThinkCMF, 等各类cms的相互转化,程序开发,网站制作,bug修复,程序杀毒,插件定制都可以提供最佳解决方案。