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

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

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


当前回答

我有同样的问题与根用户和它为我工作时,我替换

root@%

by

root@localhost

所以,如果用户'web2vi'被允许从'localhost'连接,你可以尝试:

web2vi@localhost

我远程连接到数据库了。

其他回答

快速修复工作周围和转储文件:

mysqldump --single-transaction -u root -p xyz_live_db > xyz_live_db_bkup110116.sql

我的5美分。

当我试图从视图中选择时,我也犯了同样的错误。

然而,问题似乎是这个视图,选择从另一个视图,从备份从不同的服务器恢复。

事实上,是的,用户是无效的,但从第一眼看不清楚在哪里。

//更新所有或特定的程序到你想要的,使用现有的用户(我的case -root)

1) 更新mysql。SET definer = 'root@%' WHERE 1=1 LIMIT 1000; (limit子句是由于不同的mysql版本在更新时没有使用limit或没有使用where condition而导致的)

2) 冲洗特权;//或重新启动服务器

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

DROP VIEW view_name;

我在更新mysql后得到了同样的错误。

这个错误已经被修复:

mysql_upgrade -u root

mysql_upgrade应该在每次升级MySQL时执行。它 方法检查所有数据库中的所有表是否与 MySQL服务器的当前版本。如果一个表被发现有 可能的不兼容性,它被检查。如果发现任何问题, 桌子修好了。Mysql_upgrade也升级系统表 这样你就可以利用新的特权或能力 可能是加进去的。