Skip to content
🎉 Launch sale:50% off everything over $22 — automatically applied at checkout· ends Aug 2Shop the sale →
DevOps AI ToolKit
Newsletter
All guides
AI for MySQL By James Joyner IV · · 7 min read Last reviewed Jul 2026

MySQL Error: 'ERROR 1305 (42000): FUNCTION does not exist' — Cause, Fix, and Troubleshooting Guide

Quick answer

Fix MySQL ERROR 1305 (42000) FUNCTION does not exist: space before parenthesis, missing schema qualifier, and version-specific built-ins.

  • #mysql
  • #mariadb
  • #database
  • #troubleshooting
Free toolkit

Stuck on this MySQL error? Get the free incident triage checklist

A one-page PDF — the exact steps to isolate, fix, and verify a production error like this one. No spam, unsubscribe anytime.

Overview

ERROR 1305 (42000) means MySQL could not resolve a function (or stored procedure) name you called:

ERROR 1305 (42000): FUNCTION appdb.my_calc does not exist

There are two flavors: a stored function/procedure that was never created (or lives in another schema), or a built-in function that MySQL failed to recognize — most often because of a stray space between the function name and its opening parenthesis, or because the built-in does not exist in your version/fork.

Symptoms

  • A CALL proc(...) or SELECT my_func(...) fails naming db.name.
  • A query using a newer built-in (JSON_TABLE, REGEXP_REPLACE) works on 8.0 but fails on 5.7 or an older MariaDB.
  • Copy-pasted SQL with COUNT (x) (note the space) fails as an unknown function.

Common Root Causes

1. Space between a built-in name and the parenthesis

SELECT COUNT (*) FROM orders;
ERROR 1305 (42000): FUNCTION appdb.COUNT does not exist

With IGNORE_SPACE off (the default), COUNT (*) is parsed as a user function named COUNT, which does not exist.

2. Stored routine never created or wrong schema

The function lives in analytics but you called it from appdb without qualifying it.

3. Version/fork mismatch

REGEXP_REPLACE, JSON_TABLE, and window functions exist in MySQL 8.0 but not 5.7; some built-ins differ between MySQL and MariaDB.

4. Missing DEFINER privileges hiding the routine

A routine you cannot see (no EXECUTE) can appear “not to exist.”

How to diagnose

List stored routines and their schema:

SELECT ROUTINE_SCHEMA, ROUTINE_NAME, ROUTINE_TYPE
FROM information_schema.ROUTINES
WHERE ROUTINE_NAME = 'my_calc';

Check the server version and mode for built-in issues:

SELECT VERSION();
SELECT @@sql_mode;

If the culprit is a built-in with a space, the error naming your current schema as the “function” owner is the tell.

Fixes

Remove the space so built-ins parse correctly:

SELECT COUNT(*) FROM orders;   -- no space before (

Qualify stored routines with their schema, or USE the right database:

SELECT analytics.my_calc(revenue) FROM sales;
-- or
USE analytics;
CALL my_calc();

Create the routine if it is genuinely missing:

DELIMITER //
CREATE FUNCTION analytics.my_calc(x DECIMAL(10,2))
RETURNS DECIMAL(10,2) DETERMINISTIC
BEGIN
  RETURN x * 1.2;
END //
DELIMITER ;

Grant execute rights if the routine exists but is invisible:

GRANT EXECUTE ON PROCEDURE analytics.my_calc TO 'app'@'%';

What to watch out for

  • Enabling IGNORE_SPACE lets COUNT (*) parse but also turns function names into reserved words — it changes parsing globally, so fix the spaces instead.
  • Newer built-ins silently become “missing functions” on older engines; check the version target before using window/JSON functions.
  • Stored routines are schema-scoped — always qualify them in cross-database queries.
  • MariaDB and MySQL have diverged on some functions; do not assume portability.
Free download · 368-page PDF

Fixed it? Get 500 MySQL & DevOps AI prompts — free

500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.

  • 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
  • Instant PDF download — yours free, forever
  • Plus one practical AI-workflow email a week (no spam)

Single opt-in · unsubscribe anytime · no spam.

Did this fix your issue?

Free download · 368-page PDF

Get 500 Battle-Tested DevOps AI Prompts — Free

500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.

  • 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
  • Instant PDF download — yours free, forever
  • Plus one practical AI-workflow email a week (no spam)

Single opt-in · unsubscribe anytime · no spam.