MySQL error 1449: The user specified as a definer does not exist(MySQL 错误 1449:指定为定义者的用户不存在)
问题描述
当我运行以下查询时,出现错误:
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:指定为定义者的用户不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:MySQL 错误 1449:指定为定义者的用户不存在
基础教程推荐
- 是否可以执行按位分组功能? 2021-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
- 无法解决整理冲突 2021-01-01
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
- 在 SQL 中连接多个表 2021-01-01
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
