The content of a field contains expressions. When inserting mysql, you will be prompted with an error:
err=Error 3988: Conversion from collation utf8mb4_unicode_ci into utf8_general_ci impossible for parameter
solve:
1. Modify MySQL character set
I am using docker
- Modify
mysql.cnf
maps to docker where/etc/mysql/mysql.cnf
:
[client]
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
[mysqld]
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
datadir = /var/lib/mysql
secure-file-priv= NULL
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
init_connect='SET NAMES utf8mb4'
-
-
- start command parameter addition:
-
--character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
After restarting the container, enter Mysql to view:
mysql> SHOW VARIABLES WHERE Variable_name LIKE 'character_set_%' OR Variable_name LIKE 'collation%';
+--------------------------+--------------------------------+
| Variable_name | Value |
+--------------------------+--------------------------------+
| character_set_client | utf8mb4 |
| character_set_connection | utf8mb4 |
| character_set_database | utf8mb4 |
| character_set_filesystem | binary |
| character_set_results | utf8mb4 |
| character_set_server | utf8mb4 |
| character_set_system | utf8mb3 |
| character_sets_dir | /usr/share/mysql-8.0/charsets/ |
| collation_connection | utf8mb4_unicode_ci |
| collation_database | utf8mb4_unicode_ci |
| collation_server | utf8mb4_unicode_ci |
+--------------------------+--------------------------------+
11 rows in set (0.17 sec)
2. Modify the character set of table
-
-
-
- modify the character set of a specific table:
-
-
DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-
-
-
-
- modify the character set of a specific field:
-
-
-
CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci
Read More:
- [MySQL] Note that MySQL5.1 does not support utf8mb4 Error 1115: Unknown character set:’utf8mb4′
- [Solved] mysql [ERR] 1273 – Unknown collation: ‘utf8mb4_0900_ai_ci’
- General error: 2006 MySQL server has gone away [How to Solve]
- SqlSugar Connect MySql 8.0.29 Error [How to Solve]
- MYSQL Enter password:ERROR 2003 (HY000): Can‘t connect to MySQL server on ‘localhost:3306‘
- [Solved] ERROR 2002 (HY000): Can’t connect to local MySQL server through socket’/var/lib/mysql/mysql.sock’ (2)
- [ERROR] [FATAL] InnoDB: Table flags are 0 in the data dictionary but the flags in file ./ibdata
- ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’
- (Fixed) workbench MySQL Error Code: 2013. Lost connection to MySQL server during query
- MYSQL Slave is not configured or failed to initialize properly. You must at least set –server-id
- Android connection to cloud MySQL error: java.lang.NoClassDefFoundError Failed resolution of LjavasqlSQLType
- MYSQL 5.7 Error Code: 1290. The MySQL server is running with the –secure-file-priv option so it..
- [Solved] MYSQL Error: ERROR! MySQL server PID file could not be found!
- MySql Install Error: Can‘t connect to local MySQL server through socket ‘/tmp/mysql.sock‘
- [Solved] MYSQL Command Execute Error: Can ‘t connect to local MySQL server through socket ‘/tmp/mysql.sock ‘(2) “
- How to Fix MySQL error 1005: can’t create table (errno: 150)
- Mysql Flashback Warning: C:\Program Files\MySQL\MySQL Server 8.0\bin\mysql.exe
- linux mysql ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
- MYSQL8 Startup Error: mysqld_safe error: log-error set to ‘/var/log/mariadb/mariadb.log‘
- [Solved] Django configures MySQL Error: NameError: name ”_MySQL ‘is not defined