MySQL错误1449:指定为定义者的用户不存在 [英] MySQL error 1449: The user specified as a definer does not exist
问题描述
当我运行以下查询时,我得到一个错误:
When I run the following query I get an error:
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
为什么会出现该错误?我该如何解决?
Why am I getting that error? How do I fix it?
推荐答案
当创建一个对象的用户不再存在时,将视图/触发器/过程从一个数据库或服务器导出到另一个数据库或服务器时,通常会发生这种情况.
This commonly occurs when exporting views/triggers/procedures from one database or server to another as the user that created that object no longer exists.
您有两个选择:
在最初导入数据库对象时,通过从转储中删除任何DEFINER
语句,这可能最容易做到.
This is possibly easiest to do when initially importing your database objects, by removing any DEFINER
statements from the dump.
稍后更改定义器比较棘手:
Changing the definer later is a more little tricky:
-
运行此SQL生成必要的ALTER语句
Run this SQL to generate the necessary ALTER statements
SELECT CONCAT("ALTER DEFINER=`youruser`@`host` VIEW ",
table_name, " AS ", view_definition, ";")
FROM information_schema.views
WHERE table_schema='your-database-name';
复制并运行ALTER语句
Copy and run the ALTER statements
如何更改存储过程的定义器
示例:
How to change the definer for stored procedures
Example:
UPDATE `mysql`.`proc` p SET definer = 'user@%' WHERE definer='root@%'
请小心,因为这将更改所有数据库的所有定义器.
Be careful, because this will change all the definers for all databases.
如果在使用MySQL数据库时发现以下错误:
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
.
This worked like a charm - you only have to change someuser
to the name of the missing user. On a local dev server, you might typically just use root
.
还要考虑您是否实际上需要授予用户ALL
权限,或者他们是否可以做得更少.
Also consider whether you actually need to grant the user ALL
permissions or whether they could do with less.
这篇关于MySQL错误1449:指定为定义者的用户不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!