相关推荐recommended
连接mysql:1449, “The user specified as a definer (‘mysql.infoschema‘@‘localhost‘) does not exist
作者:mmseoamin日期:2024-03-20

连接mysql:1449, “The user specified as a definer (‘mysql.infoschema‘@‘localhost‘) does not exist,第1张

       📝个人主页:五敷有你      

 🔥系列专栏:DeBug

⛺️稳中求进,晒太阳

连接mysql:1449, “The user specified as a definer (‘mysql.infoschema‘@‘localhost‘) does not exist,第2张

场景

前一天连接,一点问题没有,今早起来直接连接不上用命令行也是提示权限不够,啥也不能干。尝试过网上了的各种赋予权限的方法

某天,运行使用navcat打开服务器的数据库,报错:

 (1449, "The user specified as a definer ('mysql.infoschema'@'localhost') does not exist")

原因:

主要是因为在my.cnf配置文件中skip_name*****跳过了域名解析并且删除掉了user表中所有localhost为地址的用户,需要进行升级操作,把这些新用户重新添加回来。 

解决方案

原理:给 mysql.infoschema 用户添加权限

具体步骤:

依次执行命令:

因为用navcat已经打不开mysql了,就使用了mysql的终端,

连接mysql:1449, “The user specified as a definer (‘mysql.infoschema‘@‘localhost‘) does not exist,第3张

create user 'mysql.infoschema'@'%' identified by '密码';
grant all privileges on *.* to 'mysql.infoschema'@'%';
flush privileges;

连接mysql:1449, “The user specified as a definer (‘mysql.infoschema‘@‘localhost‘) does not exist,第4张

3条命令都执行成功,打开了。!!

连接mysql:1449, “The user specified as a definer (‘mysql.infoschema‘@‘localhost‘) does not exist,第5张

 

 这是别人的解决方案

如果mysql版本在8.0.16之后,使用 mysqld.exe --upgrade=FORCE

进行升级。

步骤如下:

要使用管理员身份运行,停掉mysql服务:net stop mysql;

进入mysql安装目录的bin目录,执行:mysqld.exe --upgrade=FORCE

稍等几分钟,更新可能有点慢(过几分钟还没完成就ctrl+c)

重启mysql服务:net start mysql

登录到mysql,查看数据库,此时不报错,然后用navicat可以正常连接上

如果mysql版本是8.0.16之前的版本,使用 mysql_upgrade -u root -p

进行升级