我遵循Laravel Sail的教程,它工作正常,但是如果我在另一台机器上克隆 repo ( docker-compose up ),尝试在容器内运行迁移时出现以下错误:
SQLSTATE[HY000] [2002] 没有这样的文件或目录(SQL:创建表
migrations
(id
int unsigned not null auto_increment 主键,migration
varchar(255) not null,batch
int not null)默认字符集 utf8mb4 collate 'utf8mb4_unicode_ci')
已经尝试了一些解决方案,但没有任何效果。
我的database.php文件:
'mysql' => [
'driver' => 'mysql',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', '/var/run/mysqld/mysqld.sock'),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [],
],
我的.env文件:
DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=code_challenge
DB_USERNAME=root
DB_PASSWORD=