Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jackjack's avatar

Migration table doesn't exist? - SQLSTATE[42S02]: Base table or view not found: 1932 Table 'database.migrations' doesn't exist in engine

I'm running Docker with Laravel & 2 MariaDB databases. Had several issues but now I'm at a roadblock, getting the following issue when running 'php artisan migrate'

[Illuminate\Database\QueryException]                                                                                                                        
  SQLSTATE[42S02]: Base table or view not found: 1932 Table 'database.migrations' doesn't exist in engine (SQL: select `migration` from `migrations` order b  
  y `batch` asc, `migration` asc)                                                                                                                             
                                                                                                                                                              

                                                                                                           
  [Doctrine\DBAL\Driver\PDOException]                                                                      
  SQLSTATE[42S02]: Base table or view not found: 1932 Table 'database.migrations' doesn't exist in engine  
                                                                                                           

                                                                                                           
  [PDOException]                                                                                           
  SQLSTATE[42S02]: Base table or view not found: 1932 Table 'database.migrations' doesn't exist in engine 

Docker says the following:

database_1      | 2017-04-27  9:59:03 139985946852096 [Warning] InnoDB: Cannot open table database/migrations from the internal data dictionary of InnoDB though the .frm file for the table exists. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting.html for how you can resolve the problem.

Tried googling around but nothing seems to work or match my specific issue./

Any help would be very much appreciated as I've been facing this issue now for too long!

0 likes
2 replies
jackjack's avatar

Sorry, should also include:

Database.php:

'mysql' => [
            'driver' => 'mysql',
            'host' => 'database',
            'port' => env('DB_PORT_MAIN', '3306'),
            'database' => 'database',
            'username' => 'root',
            'password' => 'secret',
            'unix_socket' => env('DB_SOCKET_MAIN', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'strict' => true,
            'engine' => null,
        ],

        'mysql_cms' => [
            'driver' => 'mysql',
            'host' => 'cms_database',
            'port' => env('DB_PORT_CMS', '3306'),
            'database' => 'cms_database',
            'username' => 'root',
            'password' => 'secret',
            'unix_socket' => env('DB_SOCKET_CMS', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'strict' => true,
            'engine' => null,
        ],

docker-compose.yml

version: '2'
services:
    web:
        build:
            context: ./
            dockerfile: web.docker
        volumes:
            - ./:/var/www
        ports:
            - "8003:80"
        links:
            - app
    app:
        build:
            context: ./
            dockerfile: app.docker
        volumes:
            - ./:/var/www
            - mariadb:/var/lib/mysql/data
            - /data/pgsql:/var/lib/postgresql
            - /data/redis:/var/lib/redis
        links:
            - database
            - cms_database
            - cache
        environment:
            - "DB_PORT=3306"
            - "DB_HOST=database"
            - "REDIS_PORT=6379"
            - "REDIS_HOST=cache"
    database:
        build: ./docker/mariadb
        volumes:
          - mariadb:/var/lib/mysql/database
        environment:
            - "MYSQL_ROOT_PASSWORD=secret"
            - "MYSQL_DATABASE=database"
            - "MYSQL_USER=user"
            - "MYSQL_PASSWORD=secret"
        ports:
            - "33061:3306"
    cms_database:
        build: ./docker/mariadb
        volumes:
          - mariadb:/var/lib/mysql/cms_database
        environment:
            - "MYSQL_ROOT_PASSWORD=secret"
            - "MYSQL_DATABASE=cms_database"
            - "MYSQL_USER=cms"
            - "MYSQL_PASSWORD=secret"
        ports:
            - "33062:3306"
    cache:
        image: redis:3.0
        ports:
            - "63791:6379"
volumes:
  mariadb:
jackjack's avatar
jackjack
OP
Best Answer
Level 1

Resolved!!!

Managed to fix this by stopping all containers, deleting all volumes & restarting:

docker-compose down
docker volume rm $(docker volume ls -f dangling=true -q)
docker-compose up

Then exec'd into the database container and ran the MySQL secure config:

docker exec -it database_1 bash
root@database_1:/# /usr/bin/mysql_secure_installation

Exec back into application container and run migrations:

docker exec -it app_1 bash     
root@app_1:/var/www# php artisan migrate
Migration table created successfully.
Migrating: 2014_10_12_000000_create_users_table
Migrated:  2014_10_12_000000_create_users_table
Migrating: 2014_10_12_100000_create_password_resets_table
Migrated:  2014_10_12_100000_create_password_resets_table

Hope this helps anyone else that may have been encountering the same issue as me!

1 like

Please or to participate in this conversation.