MariaDB add datas error:
SQL error [1366] [22007]: (conn=17) Incorrect string value: ‘\xE5\xBC\xA0\xE4\xB8\x89’ for column `SAOS`.`user`.`userName` at row 1
SQL:
INSERT into `user` values(1, "ZHANGSAN","123456");
The reason for this is the encoding problem. We can check the database character set encoding:
SHOW VARIABLES LIKE 'character%';
Variable_name |Value |
———————— +—————————-+
character_set_client |utf8mb4 |
character_set_connection |utf8mb4 |
character_set_database |latin1 |
character_set_filesystem |binary |
character_set_results |utf8mb4 |
character_set_server |latin1 |
character_set_system |utf8 |
character_sets_dir |/usr/share/mariadb/charsets/|
Above is the result displayed. You can see that there are two latin1 encodings. So to change the encoding, find the my.ini file at
whereis my.ini
The results are as follows:
my: /etc/my. cnf
That means this file replaces my Ini, we modify this file.
Add two lines of configuration:
default-character-set=utf8
character-set-server=utf8
Note that this file will tell you that it is read-only when it is modified. You should empower it:
sudo chmod 777 /etc/my.cnf
Then restart MariaDB.
systemctl restart mariadb.service
You need identity authentication. We can just enter the password.
Then view the database character set encoding:
In this way, insert the data just now, and the result is still an error. It seems that you need to continue to modify the configuration file.
Read More:
- [Solved] Docker Error: SyntaxError: Non-ASCII character ‘\xe5‘ in file xxx
- ArchLinux starts error after modifying MariaDB database path Can’t create test file /xxxxx/xxxxx-test
- [Solved] OpenGL PowerVR SDK Compiling Error: Could NOT find X11 (missing: X11_X11_INCLUDE_PATH X11_X11_LIB)
- [Solved] hello.s:15 Error: junk at end of line, first unrecognized character valued 0x8
- [Solved] Rancher Add User Error: x509: certificate has expired Internal error occurred: failed calling webhook “rancherauth.cattle.io”:
- [Solved] FFMPEG live encoding 2. session more error: [nvenc @ 0xa00480] OpenEncodeSessionEx failed: 0xa – invalid license key?
- [Solved] Rocketmq console connect to x.x.x.x:10911 failed Error
- [Solved] TFrecords Create Datas Error: Number of int64 values != expected. Values size: 1 but output shape: [3]
- Mysql5.7.18.1 Error 1054 (42S22): Unknown Column’password’ In’field List’ When Changing User Password
- [Solved] Leetcode Error: AddressSanitizer: SEGV on unknown address 0x55eb765425b8 (pc 0x55eb76542b86 bp 0x7ffd1bd2
- PostgreSQL insert data error: column “XXX” does not exist solution
- [Solved] error: taking address of temporary array av_make_error_string((char[AV_ERROR_MAX_STRING_SI…
- [Solved] SyntaxError:JSON.parse:unexpected character at line 1 column 1 of the JSON data
- kubeadm join Add a New Note Error [How to Solve]
- How to Solve hadoop3.x.x sh start-dfs.sh Startup Error
- QT Error: ‘C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\link.exe‘ failed
- [Solved] Hive 2.3.9 Error: Error: Unrecognized column type: UNIONTYPE (state=,code=0)
- How to Fix Microsoft SQL Server Error 1326
- AAPT: error: attribute cardBackgroundColor (aka com.x.x:cardBackgroundColor) not found.
- [Solved] Canal Error: CanalParseException: column size is not match,parse row data failed