2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

docker+laravelでGeneral error: 1812 が発生

Last updated at Posted at 2021-01-13

初めに

docker + laravelを使って、なんかプログラムを作ろうと
migrateを行った際に

$ docker exec -it docker-sample_php-fpm_1 bash
root@39aae0ad8da6:/var/www/html# php artisan migrate

   Illuminate\Database\QueryException 

  SQLSTATE[HY000]: General error: 1812 Tablespace is missing for table `laravel`.`migrations`. (SQL: select `migration` from `migrations` order by `batch` asc, `migration` asc)

  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:671
    667|         // If an exception occurs when attempting to run a query, we'll format the error
    668|         // message to include the bindings with SQL, which will make this exception a
    669|         // lot more helpful to the developer instead of just the database's errors.
    670|         catch (Exception $e) {
  > 671|             throw new QueryException(
    672|                 $query, $this->prepareBindings($bindings), $e
    673|             );
    674|         }
    675| 

      +27 vendor frames 
  28  artisan:37
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) 

が発生した。
備忘録として、メモしておく

何が起こったか?

出ているエラーをよくみてみると

Tablespace is missing for table `laravel`.`migrations`

と出ている。
dokcerのmysqlのコンテナーにログインして、テーブルを確認すると

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| laravel            |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
5 rows in set (0.01 sec)

mysql> use laravel;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
+-------------------+
| Tables_in_laravel |
+-------------------+
| failed_jobs       |
| migrations        |
| password_resets   |
| tasks             |
| users             |
+-------------------+
5 rows in set (0.00 sec)

migrationsテーブルは存在する。
migrationsテーブルの中身を見てみる。

mysql> select * from migrations;
ERROR 1812 (HY000): Tablespace is missing for table `laravel`.`migrations`.

エラーが出てくる。

解決

色々と調べてみたが、いかが手っ取り早そう

mysql> drop table migrations;
Query OK, 0 rows affected (0.02 sec)

他のテーブルでもmigrateが詰まったら
drop table tbl_name

を実行すれば良さそう。

それでは素敵なdocker lifeを

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?