gpt4 book ai didi

MySQL 错误 1449 : The user specified as a definer does not exist

转载 作者:IT老高 更新时间:2023-10-28 12:47:55 25 4
gpt4 key购买 nike

当我运行以下查询时出现错误:

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

为什么会出现这个错误?我该如何解决?

最佳答案

这通常发生在将 View /触发器/过程从一个数据库或服务器导出到另一个数据库或服务器时,因为创建该对象的用户不再存在。

你有两个选择:

1。更改定义器

最初导入数据库对象时,这可能是最容易做到的,方法是从转储中删除任何 DEFINER 语句。

稍后更改定义器有点棘手:

How to change the definer for views

  1. 运行此 SQL 以生成必要的 ALTER 语句

    SELECT CONCAT("ALTER DEFINER=`youruser`@`host` VIEW ", 
    table_name, " AS ", view_definition, ";")
    FROM information_schema.views
    WHERE table_schema='your-database-name';
  2. 复制并运行 ALTER 语句

How to change the definer for stored procedures

例子:

UPDATE `mysql`.`proc` p SET definer = 'user@%' WHERE definer='root@%'

小心,因为这会改变所有数据库的所有定义器。

2。创建丢失的用户

If you've found following error while using MySQL database:

The user specified as a definer ('someuser'@'%') does not exist`

Then you can solve it by using following :

GRANT ALL ON *.* TO 'someuser'@'%' IDENTIFIED BY 'complex-password';
FLUSH PRIVILEGES;

来自 http://www.lynnnayko.com/2010/07/mysql-user-specified-as-definer-root.html

这就像一个魅力 - 您只需将 someuser 更改为丢失用户的名称。在本地开发服务器上,您通常可能只使用 root

还要考虑您是否确实需要授予用户ALL 权限,或者他们是否可以使用更少的权限。

关于MySQL 错误 1449 : The user specified as a definer does not exist,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10169960/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com