I've been working with a simple MySQL table using Docker Compose that only included ID and NAME column. I attempted to update my myDb.sql file that initially creates the table like this:
CREATE TABLE `Person` (
`id` int(11) NOT NULL,
`firstName` varchar(50) NOT NULL, // updated this column
`lastName` varchar(50) NOT NULL // added this column
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
I updated the NAME column to firstName, and added a lastName column.
I then stopped the Docker containers by running DOCKER-COMPOSE STOP.
I then restarted the Docker containers by running DOCKER-COMPOSE UP. I even tried DOCKER-COMPOSE RESTART.
The error message I was able to print in the console was this:
SELECT '', id, `firstName` From Person<br>Unknown column 'firstName' in 'field list'
This leads me to believe that I did not restart Docker Compose correctly.
How do I restart Docker Compose so that it runs the CREATE TABLE command?
Edit
Here is my docker-compose.yml file:
version: "3.7"
services:
www:
build: .
ports:
- "8001:80"
volumes:
- ./www:/var/www/html/
links:
- db
networks:
- default
db:
image: mysql:5.7.13
ports:
- "3306:3306"
environment:
MYSQL_DATABASE: myDb
MYSQL_USER: user
MYSQL_PASSWORD: test
MYSQL_ROOT_PASSWORD: test
volumes:
- ./dump:/docker-entrypoint-initdb.d
- persistent:/var/lib/mysql
networks:
- default
phpmyadmin:
image: phpmyadmin/phpmyadmin
links:
- db:db
ports:
- 8000:80
environment:
MYSQL_USER: user
MYSQL_PASSWORD: test
MYSQL_ROOT_PASSWORD: test
volumes:
persistent:
My Dockerfile looks like this:
FROM php:7.0.30-apache
RUN docker-php-ext-install mysqli