This guide explains how to add routines to a database when using PHPMyAdmin in a cPanel account.
There are two kinds of Routines that can be added in PHPMyAdmin:
Each of these have different specific syntax requirements which this guide will not discuss in depth. Please consult the manual for your version of MySQL or MariaDB to learn the specifics of creating these different types of routines. The following is the link to MySQL 8's documentation:
MySQL 8 Docs - Stored Routines
IMPORTANT: In order to successfully add a stored routine via PHPMyAdmin, you must be logged into cPanel with the actual username and password. You cannot do this if you have logged in with a session. An example of using a session to login is when you click the orange "cP" icon from the List Accounts page in WHM.
- Login to cPanel
- Click on the PHPMyAdmin icon under the Databases section
- Click on your database in the left sidebar
- Click on the "Routines" tab in the horizontal menu near the top of the screen
- Click on the "Add Routine" link that is just to the right of the left sidebar, typically near the center of the screen.
- Add the name of the routine
- Select either "Function" or "Procedure" depending on your specific requirements
- Complete the rest of the details to generate your desired routine.
IMPORTANT: Inside of the "Definer" field, be sure to set the DEFINER to the cPanel username at localhost. For example, if the cPanel username is EXAMPLEUSERNAME, you would set the Definer field to:
`EXAMPLEUSERNAME`@`localhost`You cannot set the definer to any other user when creating stored routines via PHPMyAdmin. If you need to customize the definer to a different user, you must consult with a database administrator that has the skills and training to edit the routine via SSH or Terminal.
- Please consult the manual for your version of MySQL or MariaDB for questions about the specifics of Routine Syntax, and the various configuration options.