当前位置:网站首页>mysql 报错 is too long for user name (should be no longer than 16)
mysql 报错 is too long for user name (should be no longer than 16)
2022-07-30 01:26:00 【chen2ha】
ERROR 1470 (HY000): String '<这里是用户名,直接和谐了,就不展示了>' is too long for user name (should be no longer than 16)
- 这个报错的意思就是
user name字段太长了,超过了表结构配置的 16 位字符
通过
desc可以查看表结构,语法格式:desc <库名>.<表名>;可以看到
User字段的格式是char(16)
desc mysql.user;
+------------------------+-----------------------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------------------+-----------------------------------+------+-----+---------+-------+
| Host | char(60) | NO | PRI | | |
| User | char(16) | NO | PRI | | |
| Password | char(41) | NO | | | |
| Select_priv | enum('N','Y') | NO | | N | |
| Insert_priv | enum('N','Y') | NO | | N | |
| Update_priv | enum('N','Y') | NO | | N | |
| Delete_priv | enum('N','Y') | NO | | N | |
| Create_priv | enum('N','Y') | NO | | N | |
| Drop_priv | enum('N','Y') | NO | | N | |
| Reload_priv | enum('N','Y') | NO | | N | |
| Shutdown_priv | enum('N','Y') | NO | | N | |
| Process_priv | enum('N','Y') | NO | | N | |
| File_priv | enum('N','Y') | NO | | N | |
| Grant_priv | enum('N','Y') | NO | | N | |
| References_priv | enum('N','Y') | NO | | N | |
| Index_priv | enum('N','Y') | NO | | N | |
| Alter_priv | enum('N','Y') | NO | | N | |
| Show_db_priv | enum('N','Y') | NO | | N | |
| Super_priv | enum('N','Y') | NO | | N | |
| Create_tmp_table_priv | enum('N','Y') | NO | | N | |
| Lock_tables_priv | enum('N','Y') | NO | | N | |
| Execute_priv | enum('N','Y') | NO | | N | |
| Repl_slave_priv | enum('N','Y') | NO | | N | |
| Repl_client_priv | enum('N','Y') | NO | | N | |
| Create_view_priv | enum('N','Y') | NO | | N | |
| Show_view_priv | enum('N','Y') | NO | | N | |
| Create_routine_priv | enum('N','Y') | NO | | N | |
| Alter_routine_priv | enum('N','Y') | NO | | N | |
| Create_user_priv | enum('N','Y') | NO | | N | |
| Event_priv | enum('N','Y') | NO | | N | |
| Trigger_priv | enum('N','Y') | NO | | N | |
| Create_tablespace_priv | enum('N','Y') | NO | | N | |
| ssl_type | enum('','ANY','X509','SPECIFIED') | NO | | | |
| ssl_cipher | blob | NO | | NULL | |
| x509_issuer | blob | NO | | NULL | |
| x509_subject | blob | NO | | NULL | |
| max_questions | int(11) unsigned | NO | | 0 | |
| max_updates | int(11) unsigned | NO | | 0 | |
| max_connections | int(11) unsigned | NO | | 0 | |
| max_user_connections | int(11) | NO | | 0 | |
| plugin | char(64) | NO | | | |
| authentication_string | text | NO | | NULL | |
+------------------------+-----------------------------------+------+-----+---------+-------+
42 rows in set (0.01 sec)
通过
ALTER可以修改表结构,以下语法解析:ALTER TABLE <库名>.<表名> MODIFY <字段名> <修改的值> BINARY NOT NULL DEFAULT '';修改的数值,根据自己的实际需求调整,我这边就配置成 45 了
ALTER TABLE mysql.db MODIFY User char(45) BINARY NOT NULL DEFAULT '';
ALTER TABLE mysql.user MODIFY User char(45) BINARY NOT NULL DEFAULT '';
FLUSH PRIVILEGES;
BINARY
- binary 属性只用于
char和varchar值- 当为列指定了该属性时,将以
区分大小写的方式排序- 忽略 binary 属性时,将使用`不区分大小写的方式排序
NOT NULL
- 如果将一个列定义为 not null,将不允许向该列插入 null 值
DEFAULT
- default 属性确保在没有任何值可用的情况下,赋予某个常量值,这个值必须是常量,因为MySQL不允许插入函数或表达式值
- 此外,此属性无法用于 BLOB 或 TEXT 列
- 如果已经为此列指定了 NULL 属性,没有指定默认值时,默认值将为 NULL,否则默认值将依赖于字段的数据类型
FLUSH PRIVILEGES;
- MySQL 用户数据和权限有修改后,希望在
不重启MySQL服务的情况下直接生效,那么就需要执行这个命令
再次查看表结构,可以看到已经得到了修改
desc mysql.user;
+------------------------+-----------------------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------------------+-----------------------------------+------+-----+---------+-------+
| Host | char(60) | NO | PRI | | |
| User | char(45) | NO | PRI | | |
| Password | char(41) | NO | | | |
| Select_priv | enum('N','Y') | NO | | N | |
| Insert_priv | enum('N','Y') | NO | | N | |
| Update_priv | enum('N','Y') | NO | | N | |
| Delete_priv | enum('N','Y') | NO | | N | |
| Create_priv | enum('N','Y') | NO | | N | |
| Drop_priv | enum('N','Y') | NO | | N | |
| Reload_priv | enum('N','Y') | NO | | N | |
| Shutdown_priv | enum('N','Y') | NO | | N | |
| Process_priv | enum('N','Y') | NO | | N | |
| File_priv | enum('N','Y') | NO | | N | |
| Grant_priv | enum('N','Y') | NO | | N | |
| References_priv | enum('N','Y') | NO | | N | |
| Index_priv | enum('N','Y') | NO | | N | |
| Alter_priv | enum('N','Y') | NO | | N | |
| Show_db_priv | enum('N','Y') | NO | | N | |
| Super_priv | enum('N','Y') | NO | | N | |
| Create_tmp_table_priv | enum('N','Y') | NO | | N | |
| Lock_tables_priv | enum('N','Y') | NO | | N | |
| Execute_priv | enum('N','Y') | NO | | N | |
| Repl_slave_priv | enum('N','Y') | NO | | N | |
| Repl_client_priv | enum('N','Y') | NO | | N | |
| Create_view_priv | enum('N','Y') | NO | | N | |
| Show_view_priv | enum('N','Y') | NO | | N | |
| Create_routine_priv | enum('N','Y') | NO | | N | |
| Alter_routine_priv | enum('N','Y') | NO | | N | |
| Create_user_priv | enum('N','Y') | NO | | N | |
| Event_priv | enum('N','Y') | NO | | N | |
| Trigger_priv | enum('N','Y') | NO | | N | |
| Create_tablespace_priv | enum('N','Y') | NO | | N | |
| ssl_type | enum('','ANY','X509','SPECIFIED') | NO | | | |
| ssl_cipher | blob | NO | | NULL | |
| x509_issuer | blob | NO | | NULL | |
| x509_subject | blob | NO | | NULL | |
| max_questions | int(11) unsigned | NO | | 0 | |
| max_updates | int(11) unsigned | NO | | 0 | |
| max_connections | int(11) unsigned | NO | | 0 | |
| max_user_connections | int(11) | NO | | 0 | |
| plugin | char(64) | NO | | | |
| authentication_string | text | NO | | NULL | |
+------------------------+-----------------------------------+------+-----+---------+-------+
42 rows in set (0.01 sec)
继续执行 sql 语句,就不再报错
is too long for user name (should be no longer than 16),当然,如果配置的字符还是小了,肯定会报错,只是 16 会变成修改表结构时的数字了
边栏推荐
- 聊聊性能测试环境搭建
- Replace the executable file glibc version of the one
- How Filebeat ensures that the log file is still correctly read when the log file is split (or rolled)
- nacos集群配置详解
- STM32——OLED显示实验
- LeetCode/Scala - without the firstborn of the string of characters, the longest text string back
- 软考 --- 数据库(5)数据库控制
- 【MySQL系列】MySQL数据库基础
- 【C Primer Plus第九章课后编程题】
- How to set up hybrid login in SQL server in AWS
猜你喜欢

神经网络迭代次数的一个近似关系

遇到bug的解决办法,测试再也不背锅了

泰克Tektronix示波器软件TDS1012|TDS2002|TDS2004上位机软件NS-Scope

经典毕业设计:基于SSM实现高校后勤报修系统

Running a Fabric Application

nacos集群配置详解

The range of motion of the robot
[email protected](using passwordYES)"/>Navicat报错:1045-Access denied for user [email protected](using passwordYES)

Leetcode70. 爬楼梯

把@Transactional事务注解用到如此炉火纯青,真的强!
随机推荐
go语言解决自定义header的跨域问题
Fabric Private Data Case
Leetcode70. 爬楼梯
泰克Tektronix示波器软件TDS520|TDS1001|TDS1002上位机软件NS-Scope
泰克Tektronix示波器软件TDS420|TDS430|TDS460上位机软件NS-Scope
Performance Testing Theory 1 | Sorting out difficult problems in performance testing
多AZ双活容灾部署的云端系统架构设计说明书框架
nacos集群配置详解
接口测试自动化后起之秀-YApi接口管理平台
[Flutter] Detailed explanation of the use of the Flutter inspector tool, viewing the Flutter layout, widget tree, debugging interface, etc.
nacos的共享配置和扩展配置
Docker installs redis cluster (including deployment script)
LeetCode / Scala - 无重复字符最长子串 ,最长回文子串
Finding a 2D Array
【Vmware NSX-V基本架构及组件安装】
自学HarmonyOS应用开发(49)- 引入地图功能
【MySQL系列】MySQL数据库基础
9 common mistakes testers fall into
Meetings OA To Be Meeting && All Meetings
Missing X64 mfc140u. DLL file - > application cannot normal boot (0 xc000007b) solution