This article discusses how to troubleshoot problems that may occur when the DEFINER attribute is used with MySQL stored objects (views, triggers, functions, and stored procedures).
You may experience problems viewing or running MySQL stored objects (views, triggers, functions, and stored procedures). For example, you may receive the following error message in phpMyAdmin:
Error in processing request: No routine with name 'example' found in database 'example_db'. You might be lacking the necessary privileges to edit this routine.
Alternatively, you may experience seemingly random errors during website operation, or a loss of database functionality.
The DEFINER attribute is used to specify a MySQL user account that can access a particular stored object. However, problems can occur when the MySQL user account in a DEFINER attribute does not match the currently logged-in MySQL user. For example, this can occur when using cPanel's phpMyAdmin, which always logs in as the primary account (cPanel) user, and not as a user-defined database user.
Similarly, this problem can occur after a site migration if the DEFINER attributes in the database are not updated with the new hosting environment's database users.
To resolve this issue, you can try to log in to the database as the database user that is referenced in the DEFINER attributes. (To determine the correct database user, you may need to dump the database and examine the DEFINER attributes.) There are several ways you can log in as different database users:
You can use a MySQL client application, such as MySQL Workbench, to log in to the database as the correct database user. You will then be able to edit and run stored objects using the right identity. For information about how to use a MySQL client application to connect to your databases, please see this article.
Alternatively, you can use the mysql command-line program to log in to the database as the correct database user. You will then be able to edit and run stored objects using the right identity. For information about how to use the mysql commnand-line program, please see this article.
If you do not want to use a MySQL client application or the command line, you can create a standalone phpMyAdmin installation on your hosting account. This custom installation enables you to log in to the database as the correct database user instead of as the primary account (cPanel) user. For information about how to create a custom phpMyAdmin installation, please see this article.
Sometimes, you cannot log in to a database as the database user referenced in the DEFINER attributes. For example, a site that has been migrated from another hosting provider may have different MySQL naming conventions, and it may be impossible to create a database user with the correct name. In this case, you must do the following:
For more information about definers, please visit https://dev.mysql.com/doc/refman/8.0/en/stored-objects-security.html.
Subscribe to receive weekly cutting edge tips, strategies, and news you need to grow your web business.
No charge. Unsubscribe anytime.
Usamos cookies con el fin de personalizar para usted nuestro sitio Web y analizar el uso de éste. Usted acepta esto haciendo clic en “Acepto” o al continuar usando el sitio Web. Hay más información sobre cookies en nuestra política de privacidad.