📦

Adding to cart!

BASIC Plan

Now let's choose your domain...

👤

Accessing your account!

My Webzi

Redirecting to client area...

Help Center

Error importing MySQL stored procedures in cPanel

Error importing MySQL stored procedures in cPanel

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 that specifies the owner user of the procedure, which can prevent both the import and subsequent modification of these database objects.

This problem is especially frequent when trying to migrate a database from a local or development server to your shared hosting, as 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 incorrect DEFINER is:

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

Additionally, when the SQL file contains lines like:

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 yours.

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 later, receiving access denied messages.

Why does this happen?

In Shared Hosting environments, users don't have SUPER privileges in MySQL for security reasons. This means that:

  • You cannot create database objects specifying a DEFINER different from your current user
  • The root@localhost user is restricted only to server administrators
  • Procedures created with an incorrect DEFINER become "orphaned" and cannot be modified

Solution!

SQL file preparation

Before importing your database, you need to edit the SQL file to correct the problematic DEFINER references.

Option A: Completely remove the DEFINER (Recommended)

  • Open your SQL file in a text editor like Notepad++, Sublime Text, or VS Code
  • Search for all occurrences of: DEFINER=root@localhost``
  • Replace them with empty text (delete them completely)
  • Save the modified file

Option B: Change to the correct user

If you prefer to keep the DEFINER, change it to your cPanel database user:

  • Search for: DEFINER=root@localhost``
  • Replace with: DEFINER=your_cpanel_user@localhost``

Your cPanel user generally has the format: cpanel_user_dbname

2. User privileges verification

Before proceeding with the import:

  • Access cPanel → MySQL Databases
  • Verify that your user has "ALL PRIVILEGES" assigned to the database
  • If not, add them from the user privileges section

3. Database import

Once the file is edited:

  • Access phpMyAdmin from cPanel
  • Select your database
  • Go to the "Import" tab
  • Select your modified SQL file
  • Execute the import

The stored procedures will now be created correctly with your user as DEFINER.

It's important to keep in mind that in Shared Hosting:

  • You won't be able to execute GRANT commands to assign specific privileges
  • phpMyAdmin users are generated dynamically, which may cause some procedures to not be visible between sessions
  • Procedures created with your user will work correctly for your web applications
Let's get started!

Start TODAY for just $3.45/mo

Includes website builder, 30GB cloud storage, 200+ apps and professional email.

Intuitive panel
24/7 Support
Website builder
Get Started

30-day money-back guarantee