MySQL 8.4Lab-verified · 2026-11-29

MySQL ERROR 1305 (42000): FUNCTION lab_a.addtax does not exist

MySQL looked for the function or procedure in the database shown in the message and did not find it.

MySQL 8.4.13
1305 (42000): FUNCTION lab_a.addtax does not exist

Jump to a cause

  1. 01Misspelled function name
  2. 02CALL of a procedure that lives in another database
  3. 03DROP PROCEDURE of a procedure that is not there

Lab-verifiedReproduced and fixed on MySQL 8.4.13 · 2026-11-29 · container image mysql:8.4

ERROR 1305 shows where MySQL looked: FUNCTION lab_a.addtax does not exist means it searched the database lab_a for a function named addtax. Check both parts: the name may be misspelled, or the routine may live in a different database than the current one.

Stored functions and procedures belong to a database. A call without a database prefix uses the current database (SELECT DATABASE()).

01Misspelled function name

The function was created as add_tax, but SELECT addtax(1000) failed with ERROR 1305 (42000): FUNCTION lab_a.addtax does not exist.

information_schema.ROUTINES for the current database listed add_tax as a FUNCTION. Calling the correct name add_tax(1000) returned 1100.

Setup
Setuprun as root
CREATE FUNCTION lab_a.add_tax(p INT) RETURNS INT DETERMINISTIC
RETURN ROUND(p * 1.1);
OUTPUT
Query OK, 0 rows affected (0.01 sec)
Reproducerun as lab_a
SELECT addtax(1000) AS price;
✕ ERROR
ERROR 1305 (42000): FUNCTION lab_a.addtax does not exist
Checkrun as lab_a
SELECT ROUTINE_NAME, ROUTINE_TYPE FROM information_schema.ROUTINES WHERE ROUTINE_SCHEMA = DATABASE();
OUTPUT
+--------------+--------------+
| ROUTINE_NAME | ROUTINE_TYPE |
+--------------+--------------+
| add_tax      | FUNCTION     |
+--------------+--------------+
1 row in set (0.00 sec)
After the fixrun as lab_a
SELECT add_tax(1000) AS price;
✓ SUCCESS
+-------+
| price |
+-------+
|  1100 |
+-------+
1 row in set (0.00 sec)

02CALL of a procedure that lives in another database

close_day() was created in the shop database and lab_a had EXECUTE on it. lab_a ran CALL close_day() and got PROCEDURE lab_a.close_day does not exist: SELECT DATABASE() showed the current database was lab_a, not shop.

CALL shop.close_day() with the database prefix returned closed.

Setup
Setuprun as root
CREATE DATABASE shop;
CREATE PROCEDURE shop.close_day() SELECT 'closed' AS result;
GRANT EXECUTE ON shop.* TO lab_a;
OUTPUT
Query OK, 1 row affected (0.01 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)
Reproducerun as lab_a
CALL close_day();
✕ ERROR
ERROR 1305 (42000): PROCEDURE lab_a.close_day does not exist
Checkrun as lab_a
SELECT DATABASE();
OUTPUT
+------------+
| DATABASE() |
+------------+
| lab_a      |
+------------+
1 row in set (0.00 sec)
After the fixrun as lab_a
CALL shop.close_day();
✓ SUCCESS
+--------+
| result |
+--------+
| closed |
+--------+
1 row in set (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

03DROP PROCEDURE of a procedure that is not there

DROP PROCEDURE close_day failed with ERROR 1305, and SHOW PROCEDURE STATUS WHERE Db = 'lab_a' returned an empty set. This stops deployment scripts that drop before re-creating.

DROP PROCEDURE IF EXISTS close_day succeeded with 1 warning. SHOW WARNINGS showed it as a Note with code 1305 instead of an error.

Reproducerun as lab_a
DROP PROCEDURE close_day;
✕ ERROR
ERROR 1305 (42000): PROCEDURE lab_a.close_day does not exist
Checkrun as lab_a
SHOW PROCEDURE STATUS WHERE Db = 'lab_a';
OUTPUT
Empty set (0.00 sec)
After the fixrun as lab_a
DROP PROCEDURE IF EXISTS close_day;
SHOW WARNINGS;
✓ SUCCESS
Query OK, 0 rows affected, 1 warning (0.00 sec)

+-------+------+------------------------------------------+
| Level | Code | Message                                  |
+-------+------+------------------------------------------+
| Note  | 1305 | PROCEDURE lab_a.close_day does not exist |
+-------+------+------------------------------------------+
1 row in set (0.00 sec)

FAQ

The function exists but MySQL says FUNCTION does not exist. Why?

Check the database in the message. If it is not the database where the function was created, call it with a prefix like shop.close_day(), as above.

How do I list stored functions and procedures in MySQL?

Query information_schema.ROUTINES with ROUTINE_SCHEMA = DATABASE(), or use SHOW PROCEDURE STATUS WHERE Db = '...'. Both were used above.

How do I avoid ERROR 1305 in a deploy script?

Use DROP PROCEDURE IF EXISTS. Above it turned the error into a Note with code 1305 and the script could continue.

How we verify

Each scenario starts from fresh database users. A script runs the setup, confirms the exact error code, applies the fix and runs the statement again. The output shown is what the database printed, saved by the script.

lab_a and lab_b are ordinary users created for the test, each with full rights on a database of the same name (its default database); root is the administrator. MySQL 8.4.13