mysqldude
Error codes › 1305

MySQL & MariaDB error 1305: PROCEDURE or FUNCTION does not exist

Error message… … does not exist
Example from our test runs: FUNCTION t_0.ENCODE does not exist (8.0.46)

A CALL or function call names a stored routine the server can't find in that database. Wrong database, a typo, a routine missing from the dump, or a space after a built-in function's name.

MySQLMariaDB
SymbolER_SP_DOES_NOT_EXISTER_SP_DOES_NOT_EXIST
SQLSTATE4200042000
TypeServer errorServer error
Versionsevery release since 5.0 activeevery release since 5.5 active

What it means

Stored procedures and functions belong to a database. CALL refresh_totals() looks in the current default database; shop.refresh_totals() looks in shop. 1305 means there is no routine of that name there.

Why it happens

  • The routine lives in another database and the call isn’t qualified.
  • The routine wasn’t copied: mysqldump only includes procedures and functions with --routines (-R), so a restored copy has the tables but not the routines. Triggers are included by default, routines are not.
  • A typo or a function that only exists in another product or version (MariaDB- or MySQL-only built-ins).
  • A space between a built-in function name and its parenthesis, e.g. COUNT (*), can make the parser treat it as a user function unless IGNORE_SPACE is set, which gives this error or a syntax error.
  • The account lacks EXECUTE and has no other privilege on the routine, so it can’t see it. That normally gives 1370 instead.

How to fix it

  • Find it: SELECT routine_schema, routine_name, routine_type FROM information_schema.ROUTINES WHERE routine_name = 'refresh_totals';.
  • Qualify the call: CALL shop.refresh_totals();.
  • Back up with mysqldump --routines --events so routines survive a restore.

Reproduce it yourself

These steps are the exact test our harness runs. Use a scratch server, never production.

  1. Connect with mysql -u root -p and create a scratch database:

    CREATE DATABASE demo;
    USE demo;
  2. Run:

    CALL refresh_totals();

You get: PROCEDURE t_0.refresh_totals does not exist(11.8.9)

Verified fixes

  1. Find which database the routine lives in, then qualify the call

    CREATE PROCEDURE refresh_totals() SELECT 1;
    SELECT routine_schema = DATABASE(), routine_type FROM information_schema.ROUTINES WHERE routine_name = 'refresh_totals';

Tested on

StepMySQLMariaDB
5.65.78.08.4910.610.1111.411.8
CALL a procedure that isn't in the current database
repro
✓ 1305✓ 1305✓ 1305✓ 1305✓ 1305✓ 1305✓ 1305✓ 1305✓ 1305
Call a function from another database without qualifying it (or a misspelt built-in)
version check
✓ 1305✓ 1305✓ 1305✓ 1305✓ 1305✓ 1305✓ 1305✓ 1305✓ 1305
Find which database the routine lives in, then qualify the call
fix
✓✓✓✓✓✓✓✓✓
CALL a procedure that isn't in the current database repro
MySQL 5.6✓ 13055.7✓ 13058.0✓ 13058.4✓ 13059✓ 1305
MariaDB 10.6✓ 130510.11✓ 130511.4✓ 130511.8✓ 1305
Call a function from another database without qualifying it (or a misspelt built-in) version check
MySQL 5.6✓ 13055.7✓ 13058.0✓ 13058.4✓ 13059✓ 1305
MariaDB 10.6✓ 130510.11✓ 130511.4✓ 130511.8✓ 1305
Find which database the routine lives in, then qualify the call fix
MySQL 5.6✓5.7✓8.0✓8.4✓9✓
MariaDB 10.6✓10.11✓11.4✓11.8✓
✓works ✓ 1062fails with the error the step demonstrates ⚠works with a warning ≠runs, result differs ✗fails Tested 2026-11-25 on 5.6.51, 5.7.44, 8.0.46, 8.4.13, 9.7.4, 10.6.28, 10.11.19, 11.4.13, 11.8.9

Related errors

  • 1146 ER_NO_SUCH_TABLEexplained
  • 1370 ER_PROCACCESS_DENIED_ERROR
  • 1418 ER_BINLOG_UNSAFE_ROUTINEexplained

Where this error shows up in our guides