// MySQL error reference

MySQL error 1305: Function or procedure does not exist

The stored function or procedure you called isn't defined in that database, or a built-in function name was misspelled or followed by a space.

Error number
1305
Name
ER_SP_DOES_NOT_EXIST
SQLSTATE
42000
Category
Databases, tables and columns
Error message
%s %s does not exist

What it means

MySQL looked for a stored routine with that name in the current (or named) database and didn't find one. The message names the kind (FUNCTION or PROCEDURE) and the qualified name.

Common causes

  • Calling a routine that lives in another database without qualifying it.
  • A typo, or a built-in function that doesn't exist in this MySQL version.
  • A space between a built-in function name and its parenthesis, which makes MySQL treat it as a user function (unless IGNORE_SPACE is set).
  • Restoring a dump without its routines (mysqldump needs --routines).

How to fix it

  1. List the routines in the database.

    SHOW PROCEDURE STATUS WHERE Db = DATABASE();
    SHOW FUNCTION STATUS WHERE Db = DATABASE();
  2. Qualify the routine with its database.

    CALL reporting.refresh_totals();
  3. When dumping, include routines: mysqldump --routines --triggers shop > shop.sql.

Related errors

More databases, tables and columns errors

The code and message text are from the MySQL 8.4 Error Message Reference. Browse the full MySQL error list or search every database error.

// fewer errors, faster fixes

Work on MySQL in SQLly

A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for MySQL and the other databases you use.