gocron_sql_convert_to_utf8mb4
因为 gocron - 定时任务管理系统 默认表和字段字符集是utf8(也就是utf8mb3),所以在现下很多数据存储会有问题,最为突出的就是emoji表情
写了一个简单的转换sql:git地址 有用到的小伙伴可以拿去直接转换
#!/bin/bash HOSTNAME="127.0.0.1" #数据库地址 PORT="3306" #数据库端口 USERNAME="root" #数据库帐号 PASSWORD="password" #数据库密码 DBNAME="gocron" #数据库名称 sql=" ALTER TABLE host CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE login_log CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE setting CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE task CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE task_host CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE task_log CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; ALTER TABLE user CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; " echo ${sql} mysql -h${HOSTNAME} -P${PORT} -u${USERNAME} -p${PASSWORD} ${DBNAME} -e "${sql}"