> ## Documentation Index
> Fetch the complete documentation index at: https://kb.stablepoint.com/llms.txt
> Use this file to discover all available pages before exploring further.

# MySQL Stored Procedures

A stored procedure in a MySQL database is a query or sequence of queries that operates on your data and returns some set of results. It can be a good way to automate reporting and other common queries.

When importing a database with stored procedures, you may see lines like this:

```text theme={null}
DEFINER=`root`@`localhost`
```

or

```text theme={null}
DEFINER=`username`@`localhost`
```

The DEFINER for each stored procedure needs to be set to the MySQL user that you are importing the database as. So if this is `username_db123`, then change the lines in your `.sql` dump to say:

```text theme={null}
DEFINER=`username_db123`@`localhost`
```

The import of the stored procedures should then complete successfully.

One issue with stored procedures is that you won't be able to edit them from phpMyAdmin when logged in to cPanel, because the cPanel phpMyAdmin user is dynamically generated and doesn't match the security definer. To edit a stored procedure, the easiest way in cPanel/phpMyAdmin is to dump the procedure, edit the SQL, and then drop and re-import the specific procedure.
