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:指定为定义者的用户不存在
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01
- 更改自动增量起始编号? 2021-01-01
- SQL 临时表问题 2022-01-01
- 在SQL中,如何为每个组选择前2行 2021-01-01
- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01
- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01
