MySQL写入权限没赋值,被限制了,怎么处理

637人浏览   2023-10-23 15:29:34

在项目中遇到过mysql写入权限没赋值,被限制了,我们先看看提示什么:

数据库上提示的

服务器上提示

解决:

The user specified as a definer ('root'@'%') does not exist 此种报错主要是针对访问视图文件引起的(没有权限)

按照下图进行操作,

1.先看下mysql是否设置了环境变量,如果没设置,就需要切换到mysql的bin目录下执行命令(我的已经设置过了)

mysql -hlocalhost -uroot -pyx_3.0

2.给root用户添加权限

grant all privileges on *.* to root@"%" identified by ".";

3.刷新权限

flush privileges;


2:如果是在不知道密码情况下,可以先进行重置密码,在进行赋值权限:

1、关闭数据库服务

service mysqld stop

2、切换路径至mysql安装目录bin下面,如:/usr/local/mysql/bin,执行如下命令:

/usr/local/mysql/bin/mysqld_safe --skip-grant-tables &

3、登录并修改密码

mysql -u root #本机loalhost登录无需密码

update user set password=password("newpasswd") where user="root";

flush privileges;

4、赋值权限

grant all on *.* to 'root'@'localhost' identified by 'newpasswd' with grant option;


grant all on *.* to 'root'@'127.0.0.1' identified by 'newpasswd' with grant option;

相关推荐