mysql root 用户 grant 报错

一台mysql数据,使用root用户登录,-h指定的127.0.0.1,执行grant操作时报错:
ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)

检查root用户权限,已经有了super和grant权限了:

mysql> SELECT host,user,password,Grant_priv,Super_priv FROM mysql.user where user = 'root' \G;
*************************** 1. row ***************************
      host: 127.0.0.1
      user: root
  password: *66EF9***************************
Grant_priv: Y
Super_priv: Y
*************************** 2. row ***************************
      host: localhost
      user: root
  password: *66EF9***************************
Grant_priv: Y
Super_priv: Y

找了半天原因,排除了本机host,连接方式以及user表中host列为%的干扰,始终无法授权新用户,见了鬼了。
后来有说是因为数据库升级导致的,但是这个mysql并没有升级,版本一直为5.5
最后还是按照升级后出现无法grant的解决办法,执行了如下操作:

# mysql_upgrade -h127.0.0.1 -uroot -p'mypasswd'
Looking for 'mysql' as: mysql
Looking for 'mysqlcheck' as: mysqlcheck
mysql.Ghost                                        OK
mysql.columns_priv                                 OK
mysql.db                                           OK
mysql.ertyui                                       OK
mysql.event                                        OK
mysql.func                                         OK
mysql.general_log                                  OK
mysql.help_category                                OK
mysql.help_keyword                                 OK
mysql.help_relation                                OK
mysql.help_topic                                   OK
mysql.host                                         OK
mysql.myhexc                                       OK
mysql.ndb_binlog_index                             OK
mysql.plugin                                       OK
mysql.proc                                         OK
mysql.procs_priv                                   OK
mysql.proxies_priv                                 OK
mysql.servers                                      OK
mysql.slow_log                                     OK
mysql.tables_priv                                  OK
mysql.tempEx                                       OK
mysql.tempExT                                      OK
mysql.tempExT1                                     OK
mysql.tempMix1                                     OK
mysql.time_zone                                    OK
OK
。。。

现在再执行grant操作,发现可以了,特此记录一下。

u2

Related Posts

mysql连接失败:The driver has not received any packets from the server

解决java spring连接mysql报错问题,增加连接串参数

Read more

python cx-Oracle 驱动安装

安装oracle驱动 cx-Oracle驱动二进制版本下载地…

Read more

You Missed

本地AI时代来临:Ollama + MemPalace工作流深度指南

  • u2
  • 4月 21, 2026
  • 81 views

Raycast深度解析:这个让Mac效率重装升级的东西,到底值不值?

  • u2
  • 4月 14, 2026
  • 73 views

GitHub 25K+星标!Onyx:开源可自托管的企业级AI聊天与RAG平台

  • u2
  • 4月 8, 2026
  • 186 views

InternVL-U 统一多模态模型

  • u2
  • 4月 3, 2026
  • 162 views
InternVL-U 统一多模态模型

Everything Claude Code:开源 Agent 性能优化框架

  • u2
  • 3月 31, 2026
  • 189 views

MiroFish:群体智能预测引擎,让未来在数字沙盘中预演

  • u2
  • 3月 29, 2026
  • 275 views