-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Adminer version: 5.4.1
MySQL version: 8.4.3 through PHP extension MySQLi
I exported a database into an sql file and tried to import it on another server and got the error:
Mysql reports:
CREATE PROCEDURE update_daily_stats ()
Error in query (1064): Syntax error near '' at line 1
I asked Gemini for the reason and got the following answer:
Yes, I see the error and the reason for it. The error is caused by an issue related to the DELIMITER command when defining your stored procedure.
The specific error message from MySQL: Error in query (1064): Syntax error near '' at line 1 is misleading but points directly to the delimiter issue.
🛑 The Error and The Fix
The Error
You are using DELIMITER ;; to change the statement terminator from the default semicolon (;) to double semicolons (;;). This is correct for the CREATE PROCEDURE statement.
However, you have a blank line between the procedure header and the body, and the procedure body is missing the BEGIN ... END block that is required for a stored procedure, even if the body is empty.
Original Code Snippet (Causing Error):
DELIMITER ;;
DROP PROCEDURE IF EXISTS `update_daily_stats`;;
CREATE PROCEDURE `update_daily_stats` ();; -- Error here, no body/BEGIN...END block
DELIMITER ;The Fix
The correct syntax for creating an empty stored procedure when using a custom delimiter is to enclose the (empty) logic within BEGIN and END keywords.
Corrected Code Snippet:
DELIMITER ;;
DROP PROCEDURE IF EXISTS `update_daily_stats`;;
CREATE PROCEDURE `update_daily_stats` ()
BEGIN
-- Procedure logic goes here (currently empty)
END;;
DELIMITER ;✅ Corrected Full Script
Here is your full script with the corrected procedure definition:
-- Adminer 5.4.0 MySQL 8.0.37 dump
SET NAMES utf8;
SET time_zone = '+00:00';
SET foreign_key_checks = 0;
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
DELIMITER ;;
DROP PROCEDURE IF EXISTS `update_daily_stats`;;
CREATE PROCEDURE `update_daily_stats` ()
BEGIN
-- Add your actual procedure logic here later
END;;
DELIMITER ;
SET NAMES utf8mb4;
DROP TABLE IF EXISTS `access_ips`;
CREATE TABLE `access_ips` (
`id` int NOT NULL AUTO_INCREMENT,
`ip_address` varchar(45) COLLATE utf8mb4_unicode_ci NOT NULL,
`first_seen` datetime DEFAULT CURRENT_TIMESTAMP,
`last_seen` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`access_count` int DEFAULT '1',
`registered_user` enum('Y','N') COLLATE utf8mb4_unicode_ci DEFAULT 'N',
`country` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`notes` text COLLATE utf8mb4_unicode_ci,
PRIMARY KEY (`id`),
UNIQUE KEY `ip_address` (`ip_address`),
KEY `idx_last_seen` (`last_seen`),
KEY `idx_registered` (`registered_user`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;