简体   繁体   English

PHPMyAdmin:您可能缺少编辑此例程的必要权限

[英]PHPMyAdmin: You might be lacking the necessary privileges to edit this routine

Error in processing request: No routine with name 'daily_difference' found in database 'chamelis_wp'.处理请求时出错:在数据库“chamelis_wp”中找不到名称为“daily_difference”的例程。 You might be lacking the necessary privileges to edit this routine.您可能缺少编辑此例程的必要权限。

在此处输入图像描述

If you are using phpMyAdMin (pma) under cPanel, this error results from the fact that cPanel creates a temporary user for every session to log into pma, and therefore the database.如果您在 cPanel 下使用 phpMyAdMin (pma),则此错误是由于 cPanel 为每个 session 创建一个临时用户以登录 pma,从而登录数据库。 If you are working in a hosted environment where you cannot be granted SUPER privileges , and you are creating routines, you are in trouble.如果您在无法被授予 SUPER 权限的托管环境中工作,并且您正在创建例程,那么您就有麻烦了。 Read on.继续阅读。

Stored routines (procedures and functions) in MySQL/Mariadb have a property called DEFINER. MySQL/Mariadb 中的存储例程(过程和函数)有一个名为 DEFINER 的属性。 This stores the username of the the database user who "owns" that routine.这存储了“拥有”该例程的数据库用户的用户名。 If a db user opens phpMyAdmin (pma) and creates a new routine without explicitly declaring the DEFINER, DEFINER will be populated with the current username.如果一个 db 用户打开 phpMyAdmin (pma) 并创建一个新例程而不显式声明 DEFINER,则 DEFINER 将填充当前用户名。 Only a db user that has SUPER permissions can create a routine and declare another user as the DEFINER.只有拥有 SUPER 权限的 db 用户才能创建例程并将另一个用户声明为 DEFINER。 Non-SUPER users can only declare themselves as the DEFINER, or leave it blank and the db does it for them.非 SUPER 用户只能将自己声明为 DEFINER,或者将其留空并由 db 为他们完成。 So the db user that you are logged in as gets to be the DEFINER for all routines you create during that session.因此,您登录的 db 用户将成为您在 session 期间创建的所有例程的定义者。

The problem you have encountered arises because您遇到的问题是因为

a.一个。 only the DEFINER of a routine, or a user with SUPER permissions, can edit or export a routine.只有例程的 DEFINER 或具有 SUPER 权限的用户才能编辑或导出例程。 If a (non-SUPER) user logs in to pma and tries to edit or export an existing routine, then unless they are the DEFINER of that routine they get the error you are seeing, and they cannot access the routine.如果(非超级)用户登录 pma 并尝试编辑或导出现有例程,那么除非他们是该例程的定义者,否则他们会收到您看到的错误,并且他们无法访问该例程。

b.湾。 Even if you have created database user accounts in cPanel, cPanel will not use any of these to launch pma.即使您在 cPanel 中创建了数据库用户帐户,cPanel 也不会使用其中任何一个来启动 pma。 Under cPanel you are automatically logged using a temp username that it generates.在 cPanel 下,您会使用它生成的临时用户名自动登录。 You do not get to see the pma login page - the login happens off-screen - and you are taken straight into the pma home page.您看不到 pma 登录页面 - 登录发生在屏幕外 - 您会直接进入 pma 主页。 You have no control over the username/password used.您无法控制使用的用户名/密码。

d. d。 When you start a new cPanel session (eg at the start of each day's work), cPanel changes the temp db user name that it uses to log you into pma.当您启动一个新的 cPanel session(例如在每天工作开始时)时,cPanel 会更改它用来让您登录到 pma 的 temp db 用户名。 cPanel usernames all have this pattern: "cpses_db...@localhost", where the dots are filled alphanumerics like "hmxbj8s2". cPanel 用户名都有这种模式:“cpses_db...@localhost”,其中的点是填充的字母数字,如“hmxbj8s2”。 I have just logged in and the pma home page tells me that the current database user is "cpses_dbhmxbj8s2@localhost".我刚刚登录,pma 主页告诉我当前数据库用户是“cpses_dbhmxbj8s2@localhost”。 If I close pma, log out of cPanel, log back into cPanel then reopen pma, the db user name will change.如果我关闭 pma,退出 cPanel,重新登录 cPanel 然后重新打开 pma,db 用户名将更改。 I just did that and the db user for this new session is "cpses_db0z35t107@localhost".我刚刚这样做了,这个新的 session 的 ​​db 用户是“cpses_db0z35t107@localhost”。

e. e. If I had created a new routine during my previous session, then the DEFINER for that routine would still be "cpses_dbhmxbj8s2@localhost".如果我在之前的 session 期间创建了一个新例程,那么该例程的 DEFINER 仍然是“cpses_dbhmxbj8s2@localhost”。 Now that I am logged in as "cpses_db0z35t107@localhost", I cannot edit or export that routine.现在我以“cpses_db0z35t107@localhost”身份登录,我无法编辑或导出该例程。 Without a backup or copy of that routine, I have completely lost access to it (it is now, effectively, "orphaned").如果没有该例程的备份或副本,我完全无法访问它(它现在实际上是“孤立的”)。 The only way to get access is to recreate it using a script without a DEFINER statement in the current session so the the current db user becomes the DEFINER.获得访问权限的唯一方法是使用当前 session 中没有 DEFINER 语句的脚本重新创建它,以便当前的 db 用户成为 DEFINER。 That user can now edit the routine.该用户现在可以编辑例程。 This means that every day you would have to recreate all the procedures you want to work on.这意味着您每天都必须重新创建您想要处理的所有程序。 If you forget to export all the routines changed during the previous session, then you have LOST THOSE CHANGES.如果您忘记导出之前 session 期间更改的所有例程,那么您将丢失这些更改。

f. F。 Another problem is that if you are also connecting to the database externally using eg MySQL Workbench, logging in using a db user you have created, then you can do everything except edit any routines created under pma because these have "cpses_db..." user as the DEFINER.另一个问题是,如果您还使用例如 MySQL 工作台从外部连接到数据库,使用您创建的 db 用户登录,那么您可以执行所有操作,除了编辑在 pma 下创建的任何例程,因为这些具有“cpses_db ...”用户作为定义者。

THE SOLUTIONS:解决方案:

  1. Install your own copy of pma in your hosted enviroment if that option is available in cPanel.如果该选项在 cPanel 中可用,则在您的托管环境中安装您自己的 pma 副本。 This will have to be installed in a folder in the public-html section of the site so you can access it directly from your browser eg https://example.com/pmamyadmin/index.php .这必须安装在站点的 public-html 部分的文件夹中,以便您可以直接从浏览器访问它,例如https://example.com/pmamyadmin/index.php Login using a user you have created for your database.使用您为数据库创建的用户登录。 This user becomes the DEFINER for all your routines and so long as you always use this username, you can always access your routines.此用户成为您所有例程的定义者,只要您始终使用此用户名,您就可以随时访问您的例程。 (Never use cPanel's pma ) (永远不要使用 cPanel 的 pma )

Be aware that having a copy of pma in the public_html section of your site introduces security issues.请注意,在您网站的 public_html 部分拥有 pma 的副本会引入安全问题。 Definitely require passwords in pma's config and if practical use .htaccess to limit access to just your IP, etc. But that's another topic.在 pma 的配置中绝对需要密码,如果实际使用 .htaccess 来限制对 IP 等的访问,那是另一个话题。

  1. Always access the database externally (assuming your host permits this) using a local copy of pma or another client like MySQL Workbench.始终使用 pma 的本地副本或 MySQL Workbench 等其他客户端从外部访问数据库(假设您的主机允许这样做)。 Again, this allows you to control the username for every session.同样,这允许您控制每个 session 的用户名。

FINALLY最后

  1. If neither of these works for you and you must use cPanel's pma, then export all your routines at the end of every session and recreate them (with no DEFINER statement) at the start of the next session.如果这些都不适合您并且您必须使用 cPanel 的 pma,则在每个 session 的末尾导出所有例程并在下一个 session 的开头重新创建它们(没有 DEFINER 语句)。 Currently pma doesn't include the DROP in the routine export function (there a change request in for this) so you have to use a database export to get them included.目前 pma 在例程导出 function 中不包含 DROP(对此有更改请求),因此您必须使用数据库导出来包含它们。 Unless you want a full backup anyway, you just need to export the structure of one table to get this export to work.除非您无论如何都想要完整备份,否则您只需要导出一个表的结构即可使此导出工作。 Make sure you click the "Include DROP..." and "Include Routines..." in the export definition.确保单击导出定义中的“包括 DROP...”和“包括例程...”。 Edit the export to delete the table definition and globally replace the "DEFINER= cpses_db...@localhost " with "" before using it to recreate the routines next session.编辑导出以删除表定义并将“DEFINER= cpses_db...@localhost ”全局替换为“”,然后再使用它重新创建下一个 session 的例程。

Hope that helps.希望有帮助。

I FIX THIS ISSUE IN CPANEL我在 CPANEL 中解决了这个问题

This shows that there is lack of routines ( Function, Procedures ) privilege for the current user.这表明当前用户缺少例程 ( Function, Procedures ) 权限。 This will cause even the edit button of routines to be disabled.这甚至会导致例程的编辑按钮被禁用。

In CPanel there is default user that you can not manage their privileges, So, you can not add or remove their privileges.在 CPanel 中有默认用户,您无法管理他们的权限,因此,您无法添加或删除他们的权限。

<<<<< HOW I FIX IT >>>>> : <<<<< 我如何修复它 >>>>>

FIRST第一的

Drop all routines(Function, Procedure) that you have no privilege from your database从数据库中删除您没有权限的所有例程(函数、过程)

SECOND ( import sql file again ) SECOND (再次导入 sql 文件)

Find the sql file used to import database and remove DEFINER= root @ localhost everywhere.找到用于导入数据库的 sql 文件,去掉所有地方的 DEFINER= root @ localhost Then import Edited sql file after remove DEFINER= root @ localhost .然后在删除 DEFINER= root @ localhost后导入 Edited sql 文件。

I think this solution can help someone.我认为这个解决方案可以帮助某人。 Thanks谢谢

It sounds like you don't have permission to edit it, or you're trying to edit it from the wrong DB (schema).听起来您没有编辑它的权限,或者您试图从错误的数据库(模式)中编辑它。 Run the following to see which DB it is on: show function status like '%daily%';运行以下命令查看它在哪个数据库上: show function status like '%daily%'; show procedure status like '%daily%';显示程序状态,如“%daily%”;

Are you trying to edit it by executing a statement or by using the gui?您是尝试通过执行语句还是使用 gui 来编辑它? If by executing a statement, can you provide your statement?如果通过执行一个语句,你能提供你的语句吗? If by statement, make sure you've run this first: use db_name_here;如果通过语句,请确保您首先运行:使用 db_name_here;

Then try to edit your routine again.然后尝试再次编辑您的例程。

Did your user create the procedure, or another user created it?是您的用户创建了该过程,还是其他用户创建了它? You may not have permission to modify an user's procedure.您可能无权修改用户的过程。 You can see who created it by running: show create procedure daily_difference;您可以通过运行查看是谁创建的: show create procedure daily_difference;

Then see if you have permission to edit procedures by running the below statement - you need "ALTER ROUTINE" privilege: show grants for Your_username_here;然后通过运行以下语句查看您是否有权编辑程序 - 您需要“ALTER ROUTINE”权限:显示 Your_username_here 的授权;

If a user with super privilege created it, you won't be able to edit it - you'll need them to, or you will need to get super privilege.如果具有超级权限的用户创建了它,您将无法对其进行编辑 - 您需要他们这样做,或者您需要获得超级权限。

I'm replying partly as I have a work around and partly for the comedy, as GoDaddy sent me this page as a solution to this problem where, yes the problem is defined but no, there's no solution.我的回复部分是因为我有一个解决方案,部分是为了喜剧,因为 GoDaddy 向我发送了这个页面作为这个问题的解决方案,是的,问题已定义,但没有,没有解决方案。

I had to rebuild my SPs in phpMyadmin but for the DEFINER where root@localhost was present, using an account I had created and could use - account@localhost.我必须在 phpMyadmin 中重建我的 SP,但是对于存在 root@localhost 的 DEFINER,使用我创建的并且可以使用的帐户 - account@localhost。 cPanel doesn't expose the root account AFAIK. cPanel 不公开根帐户 AFAIK。

I didn't have all my SPs' definitions elsewhere.我在其他地方没有我所有的 SP 定义。 But I found that in cPanel \ files \ backup \ the files from there of the MySQL DBs had the SP definitions.但我发现在 cPanel\files\backup\MySQL DB 的文件中有 SP 定义。 That may not be in your hosting package.这可能不在您的托管 package 中。 Backing up from phpMyAdmin didn't help as I still lacked the privileges to make the back up with the definitions.从 phpMyAdmin 备份并没有帮助,因为我仍然缺乏使用定义进行备份的权限。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM