When working with MySQL databases that include stored procedures, it's common to encounter errors during import in shared hosting environments with cPanel. These errors are usually related to the DEFINER parameter, which specifies the owner of the procedure, and can prevent both the import and subsequent modification of these database objects.
This issue is especially common when migrating a database from a local or development server to your shared hosting, since exported SQL files usually contain references to the root@localhost user, which is not available in shared environments for security reasons.
The most common error you'll see when trying to import stored procedures with an incorrect DEFINER is:
Additionally, when the SQL file contains lines such as:
- CREATE DEFINER=`root`@`localhost` PROCEDURE `my_procedure`(
The import will be rejected because you don't have the necessary privileges to create objects with a DEFINER different from your own.
Another common symptom is that, even if you manage to import the procedures somehow, you won't be able to modify or delete them from phpMyAdmin afterward, receiving access denied messages.
In Shared Hosting environments, users don't have SUPER privileges in MySQL for security reasons. This means that:
Before importing your database, you need to edit the SQL file to fix the problematic DEFINER references.
Option A: Completely remove the DEFINER (Recommended)
Option B: Change to the correct user
If you prefer to keep the DEFINER, change it to your cPanel database user:
Your cPanel user generally follows the format: cpanel_user_dbname
Before proceeding with the import:
Once the file has been edited:
The stored procedures will now be created correctly with your user as the DEFINER.
It's important to keep in mind that on Shared Hosting: