I have the Problem that I want Docker Compose to directly import my Database.sql file after setting up MySQL. But it always throws me the Error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELIMITER |' at line 1
But somehow when I import it through phpMyAdmin in Browser it works perfectly fine.
This is my docker-compose.yml
:
version: "3.2"
services:
php:
build: './php/'
networks:
- backend
volumes:
- ./www/:/var/www/html/
apache:
build: './apache/'
depends_on:
- php
- mysql
networks:
- frontend
- backend
ports:
- "8081:80"
volumes:
- ./www/:/var/www/html/
mysql:
image: mysql:5.7
volumes:
- ./mysql:/tmp/database
command: mysqld --max_allowed_packet=32505856 --user=root --init-file="/tmp/database/schema.sql"
networks:
- backend
environment:
- MYSQL_ROOT_PASSWORD=root
phpmyadmin:
image: phpmyadmin/phpmyadmin
links:
- mysql
ports:
- '8082:80'
environment:
MYSQL_USERNAME: root
MYSQL_ROOT_PASSWORD: root
PMA_HOST: mysql
networks:
- backend
networks:
frontend:
backend:
This is an Example Snippet of my .sql File which gets executed:
-- phpMyAdmin SQL Dump
-- version 4.8.2
-- https://www.phpmyadmin.net/
--
-- Host: mysql
-- Generation Time: Aug 20, 2018 at 08:30 AM
-- Server version: 5.7.23
-- PHP Version: 7.2.6
DELIMITER $$
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
--
-- Database: `database`
--
CREATE DATABASE IF NOT EXISTS `databasetest` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE `databasetest`;
--
-- Procedures
--
DROP PROCEDURE IF EXISTS `sp_filestatus_get`$$
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_filestatus_get` (IN `filename_name` VARCHAR(500), IN `kampagne_name` VARCHAR(100), IN `outlet_name` VARCHAR(100)) NO SQL
... Some more stuff
END;
Did I miss something in the configuration? Or why doesnt it work with compose but directly in phpMyAdmin it works?