当我运行以下查询时,我得到一个错误:

SELECT
  `a`.`sl_id`                     AS `sl_id`,
  `a`.`quote_id`                  AS `quote_id`,
  `a`.`sl_date`                   AS `sl_date`,
  `a`.`sl_type`                   AS `sl_type`,
  `a`.`sl_status`                 AS `sl_status`,
  `b`.`client_id`                 AS `client_id`,
  `b`.`business`                  AS `business`,
  `b`.`affaire_type`              AS `affaire_type`,
  `b`.`quotation_date`            AS `quotation_date`,
  `b`.`total_sale_price_with_tax` AS `total_sale_price_with_tax`,
  `b`.`STATUS`                    AS `status`,
  `b`.`customer_name`             AS `customer_name`
FROM `tbl_supplier_list` `a`
  LEFT JOIN `view_quotes` `b`
    ON (`b`.`quote_id` = `a`.`quote_id`)
LIMIT 0, 30

错误信息是:

#1449 - The user specified as a definer ('web2vi'@'%') does not exist

为什么会出现这个错误?我该怎么解决呢?


当前回答

如果这是一个存储过程,你可以这样做:

UPDATE `mysql`.`proc` SET definer = 'YournewDefiner' WHERE definer='OldDefinerShownBefore'

但这是不建议的。

对我来说,更好的解决方案是创建定义器:

create user 'myuser' identified by 'mypass';
grant all on `mytable`.* to 'myuser' identified by 'mypass';

其他回答

您的视图“view_quotes”可能已经从“web2vi”是有效用户的另一个数据库复制到“web2vi”不是有效用户的数据库。 将“web2vi”用户添加到数据库或更改视图(通常删除DEFINER='web2vi'@'%'部分并执行脚本将完成此操作)

解决方案只是一个单行查询如下:

grant all on *.* to 'ROOT'@'%' identified by 'PASSWORD' with grant option;

将ROOT替换为mysql用户名。 将PASSWORD替换为mysql密码。

在我的例子中,我在那个表上有一个触发器,我不能更新数据得到相同的错误。

MySQL错误1449:指定为定义者的用户不存在

解决方案是删除该表上的触发器并重新创建它们,这解决了问题,因为触发器是由来自另一个服务器的另一个用户创建的,并且在更改托管公司后,用户名在新服务器上更改了。这是我的意见

grant all on *.* to 'username'@'%' identified by 'password' with grant option;

例子:

grant all on *.* to 'web2vi'@'%' identified by 'password' with grant option;

在我的例子中,删除所有视图解决了这个问题。

DROP VIEW view_name;