MySQL数据库之MySQL5.7创建用户时报错
小标 2018-09-05 来源 : 阅读 2678 评论 0

摘要:本文主要向大家介绍了MySQL数据库之MySQL5.7创建用户时报错 ,通过具体的内容向大家展现,希望对大家学习MySQL数据库有所帮助。

本文主要向大家介绍了MySQL数据库之MySQL5.7创建用户时报错 ,通过具体的内容向大家展现,希望对大家学习MySQL数据库有所帮助。

1 故障现象:
在创建用户时候,提示以下错误:

root@localhost Tue Oct 24 09:57:41 2017 09:57:41 [mysql]> create user ‘liufofu‘@‘5.5.5.5‘ identified by ‘liufofu‘; 

ERROR 1805 (HY000): Column count of mysql.user is wrong. Expected 45, found 43. The table is probably corrupted
2 原因分析
2.1 根据提示以为是数据表出问题了,赶紧查查看,但是数据表可以正常查询

root@localhost Tue Oct 24 09:54:15 2017 09:54:15 [(none)]> select count(*) from mysql.user where user=‘liufofu‘ and host=‘5.5.5.5‘;
+----------+
| count(*) |
+----------+
| 0 |
+----------+
1 row in set (0.01 sec)
2.2 对数据表进行一次check table操作

root@localhost Tue Oct 24 09:57:50 2017 09:57:50 [mysql]> check table user;
+------------+-------+----------+----------+
| Table | Op | Msg_type | Msg_text |
+------------+-------+----------+----------+
| mysql.user | check | status | OK |
+------------+-------+----------+----------+
1 row in set (0.00 sec)

2.3 进行了以上操作后,发现还是不行。
跟使用人员进行沟通后,得出结果是:用户在创建时选择的是MySQL5.7的版本,而导入的备份文件为MySQL5.6的,版本不一致导致MySQL系统表有差异所之后。

3 解决方案
知道问题后,处理方案就很容易了,升级系统表即可。

[ 09:59:27-root@liufofu:3311 ]#/usr/local/mysql-5.7.18/bin/mysql_upgrade -S /data/mysql/3311/mysql.sock
Checking if update is needed.
Checking server version.
Running queries to upgrade MySQL server.
Checking system database.
mysql.columns_priv OK
mysql.db OK
mysql.engine_cost OK
mysql.event OK
mysql.func OK
mysql.general_log OK
mysql.gtid_executed OK
mysql.help_category OK
mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
mysql.innodb_index_stats OK
mysql.innodb_table_stats OK
mysql.ndb_binlog_index OK
mysql.plugin OK
mysql.proc OK
mysql.procs_priv OK
mysql.proxies_priv OK
mysql.server_cost OK
mysql.servers OK
mysql.slave_master_info OK
mysql.slave_relay_log_info OK
mysql.slave_worker_info OK
mysql.slow_log OK
mysql.tables_priv OK
mysql.time_zone OK
mysql.time_zone_leap_second OK
mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
The sys schema is already up to date (version 1.5.1).
Found 0 sys functions, but expected 22. Re-installing the sys schema.
Upgrading the sys schema.
Checking databases.
sys.sys_config OK
Upgrade process completed successfully.
Checking if update is needed.

到此用户的问题得到了解决。

4 参考资料:

4.1 mysql_upgrade官方文档
https://dev.mysql.com/doc/refman/5.7/en/mysql-upgrade.html
4.2 create user官方文档
MySQL5.7之前基本都是通过grant来创建用户,而从5.7开始建议使用create user来创建用户。
https://dev.mysql.com/doc/refman/5.7/en/create-user.html    

以上就介绍了MySQL的相关知识,希望对MySQL有兴趣的朋友有所帮助。了解更多内容,请关注职坐标数据库MySQL频道!

本文由 @小标 发布于职坐标。未经许可,禁止转载。
喜欢 | 0 不喜欢 | 0
看完这篇文章有何感觉?已经有0人表态,0%的人喜欢 快给朋友分享吧~
评论(0)
后参与评论

您输入的评论内容中包含违禁敏感词

我知道了

助您圆梦职场 匹配合适岗位
验证码手机号,获得海同独家IT培训资料
选择就业方向:
人工智能物联网
大数据开发/分析
人工智能Python
Java全栈开发
WEB前端+H5

请输入正确的手机号码

请输入正确的验证码

获取验证码

您今天的短信下发次数太多了,明天再试试吧!

提交

我们会在第一时间安排职业规划师联系您!

您也可以联系我们的职业规划师咨询:

小职老师的微信号:z_zhizuobiao
小职老师的微信号:z_zhizuobiao

版权所有 职坐标-一站式AI+学习就业服务平台 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
 沪公网安备 31011502005948号    

©2015 www.zhizuobiao.com All Rights Reserved