MySQL 创建算法=未定义的定义器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17600564/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 18:06:38  来源:igfitidea点击:

CREATE ALGORITHM=UNDEFINED DEFINER

mysqldatabasephpmyadmin

提问by mrakodol

I make a backup of some database from distance server, and I had an problem on my local server when I trying to import that backup. I get an error in this line:

我从远程服务器备份了一些数据库,当我尝试导入该备份时,我在本地服务器上遇到了问题。我在这一行收到一个错误:

CREATE ALGORITHM=UNDEFINED DEFINER=root@% SQL SECURITY DEFINER VIEW tematics_field AS select.....

CREATE ALGORITHM=UNDEFINED DEFINER=root@% SQL SECURITY DEFINER VIEW tematics_field AS select.....

Both server have a mysql 5.5.2x. And users are different in that two servers.

两台服务器都有一个 mysql 5.5.2x。和用户不同的是那两台服务器。

采纳答案by Bill Karwin

You need to put the hostname (or wildcard in this case) in single-quotes:

您需要将主机名(或本例中的通配符)放在单引号中:

CREATE ALGORITHM=UNDEFINED DEFINER=root@'%' SQL SECURITY DEFINER VIEW tematics_field AS 
select.....

回答by mrakodol

I only try to:

我只尝试:

CREATE VIEW tematics_field AS select....

And all is work perfectly and import is well done.

一切都很好,导入也做得很好。

回答by Niroshan

MySql Error: #1227 – Access denied; you need (at least one of) the SUPER privilege(s) for this operation

MySql 错误:#1227 – 拒绝访问;您需要(至少其中之一)此操作的 SUPER 权限

CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY INVOKER VIEW `inventory_stock_1` AS SELECT DISTINCT `legacy_stock_status`.`product_id` AS `product_id`,`legacy_stock_status`.`website_id` AS `website_id`,`legacy_stock_status`.`stock_id` AS `stock_id`,`legacy_stock_status`.`qty` AS `quantity`,`legacy_stock_status`.`stock_status` AS `is_salable`,`product`.`sku` AS `sku` FROM (`cataloginventory_stock_status` `legacy_stock_status` JOIN `decg_catalog_product_entity` `product` ON(`legacy_stock_status`.`product_id` = `product`.`entity_id`)) ;

Fixed Solution:

固定解决方案:

The problem is you set definer as root, which is not your current running user, that's why you need to SUPER privilege. you can create a user called root in RDS, and use root to run the command, or simply

问题是您将定义者设置为 root,这不是您当前正在运行的用户,这就是您需要SUPER privilege的原因。您可以在RDS中创建一个名为root的用户,并使用root运行命令,或者干脆

CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY INVOKER

change to:

改成:

CREATE ALGORITHM=UNDEFINED DEFINER=CURRENT_USER SQL SECURITY INVOKER

read more about CURRENT_USER Final SQL query looks like

阅读有关 CURRENT_USER 最终 SQL 查询的更多信息

CREATE ALGORITHM=UNDEFINED DEFINER=CURRENT_USER SQL SECURITY INVOKER VIEW `inventory_stock_1` AS SELECT DISTINCT `legacy_stock_status`.`product_id` AS `product_id`,`legacy_stock_status`.`website_id` AS `website_id`,`legacy_stock_status`.`stock_id` AS `stock_id`,`legacy_stock_status`.`qty` AS `quantity`,`legacy_stock_status`.`stock_status` AS `is_salable`,`product`.`sku` AS `sku` FROM (`cataloginventory_stock_status` `legacy_stock_status` JOIN `decg_catalog_product_entity` `product` ON(`legacy_stock_status`.`product_id` = `product`.`entity_id`)) ;

Thank you.From: MazziTorch

谢谢。来自:MazziTorch

回答by Bijendra Ch

 CREATE ALGORITHM=UNDEFINED DEFINER=root@% SQL SECURITY DEFINER VIEW tematics_field AS select.....
Please remove "ALGORITHM=UNDEFINED DEFINER=root@% SQL SECURITY DEFINER" and keep like "CREATE VIEW tematics_field AS select.....
it will work while importing or direct pasting under sql tab