mysql输入中文出现ERROR 1366

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
云数据库 RDS MySQL,高可用系列 2核4GB
简介: mysql输入中文出现如下错误:ERROR 1366: 1366: Incorrect string value: '\xE6\xB0\xB4\xE7\x94\xB5...' for column 'introduce' at row 1这是因为mysql编码的问题 打开mysqlmysql -u root -p输入密码后,输入下面这一行代码来显示

mysql输入中文出现如下错误:

ERROR 1366: 1366: Incorrect string value: '\xE6\xB0\xB4\xE7\x94\xB5...' for column 'introduce' at row 1

这是因为mysql编码的问题
打开mysql

mysql -u root -p

输入密码后,输入下面这一行代码来显示mysql当前使用的编码:

SHOW VARIABLES LIKE 'character%';

这里写图片描述

由上图能看出,database和server的字符集使用了latin1编码方式,latin1编码是不支持中文的,所以存储中文时会出现错误。

解决办法:修改 /etc/mysql/my.cnf (这是mysql默认的安装路径)
打开my.cnf后,在文件内的[mysqld]下增加如下几行代码:

[client]
default-character-set=utf8
[mysqld]
character-set-server=utf8
[mysql]
default-character-set=utf8

保存并退出。
重启mysql服务

service mysql restart

现在再把mysql中有问题的表(table)删掉重建即可结局问题。

参考文献:
http://www.cr173.com/html/50452_1.html
http://blog.sina.com.cn/s/blog_673faff10100qbyh.html
http://www.dutycode.com/post-5.html

相关实践学习
如何在云端创建MySQL数据库
开始实验后,系统会自动创建一台自建MySQL的 源数据库 ECS 实例和一台 目标数据库 RDS。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
5月前
|
关系型数据库 MySQL
mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file
mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file
190 0
|
5月前
|
SQL 关系型数据库 MySQL
SQL Error (2013): Lost connection to MySQL server at 'waiting for initial communication packet', sys...
SQL Error (2013): Lost connection to MySQL server at 'waiting for initial communication packet', sys...
114 0
|
2月前
|
SQL 关系型数据库 MySQL
mysql密码错误-ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using passwor:yes)
这篇文章提供了解决MySQL数据库"Access denied for user 'root'@'localhost' (using password: YES)"错误的方法,通过跳过密码验证、修改root密码,然后重启服务来解决登录问题。
mysql密码错误-ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using passwor:yes)
|
5月前
|
关系型数据库 MySQL
ERROR 1449 (HY000): The user specified as a definer (‘mysql.infoschema‘@‘localhost‘) does not exist
ERROR 1449 (HY000): The user specified as a definer (‘mysql.infoschema‘@‘localhost‘) does not exist
74 0
|
3月前
|
缓存 关系型数据库 MySQL
error: Failed dependencies: mariadb-connector-c-config is obsoleted by mysql-community-server-8.0.36-1.el7.x86_64 问题解决
error: Failed dependencies: mariadb-connector-c-config is obsoleted by mysql-community-server-8.0.36-1.el7.x86_64 问题解决
135 19
|
2月前
|
关系型数据库 MySQL Java
【Azure 应用服务】应用服务连接 Azure MySQL 一直失败,报错 Create connection error
【Azure 应用服务】应用服务连接 Azure MySQL 一直失败,报错 Create connection error
|
3月前
|
关系型数据库 MySQL Linux
error: Failed dependencies: libncurses.so.5()(64bit) is needed by mysql-community-client-8.0.36-1.el7.x86_64 libtinfo.so.5()(64bit) is needed by mysql-community-client-8.0.36-1.el7.x86_64 如何解决?
error: Failed dependencies: libncurses.so.5()(64bit) is needed by mysql-community-client-8.0.36-1.el7.x86_64 libtinfo.so.5()(64bit) is needed by mysql-community-client-8.0.36-1.el7.x86_64 如何解决?
292 3
|
5月前
|
关系型数据库 MySQL 数据库连接
解决 mysql8.0 ERROR 1045 (28000): Access denied for user ‘ODBC‘@‘localhost‘ (using password: NO)用户访问拒绝
解决 mysql8.0 ERROR 1045 (28000): Access denied for user ‘ODBC‘@‘localhost‘ (using password: NO)用户访问拒绝
1266 52
解决 mysql8.0 ERROR 1045 (28000): Access denied for user ‘ODBC‘@‘localhost‘ (using password: NO)用户访问拒绝
|
3月前
|
关系型数据库 MySQL 测试技术
MySQL 报错 ERROR 1709: Index column size too large
MySQL 报错 ERROR 1709: Index column size too large
171 4
|
3月前
|
关系型数据库 MySQL
mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file
mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file
135 2
下一篇
无影云桌面