Ste*_*oni 6 php mysql laravel docker-compose laradock
我的 laradock 项目遇到了麻烦:我已经下载并安装了 docker,并且我已经使用 laradock 成功完成了我的 laravel 项目的设置。我使用 php 7、laravel(5.5.14) 和最新版本的 laradock。我开始在 shell 中编写我的项目:
docker-compose up -d nginx mysql
Run Code Online (Sandbox Code Playgroud)
并启动所有服务。我的 env 文件是:
DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=root
DB_PASSWORD=root
Run Code Online (Sandbox Code Playgroud)
但是当我尝试使用迁移时
php artisan migrate
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known (SQL: select * from information_schema.tables where table_schema = homestead and table_name = migrations)
SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known
PDO::__construct(): php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known
Run Code Online (Sandbox Code Playgroud)
我的名为 homestead 的数据库已创建并且可以正常工作。在我的 Laravel 项目中,在迁移文件夹下我有 3 个文件 php:create_user_table、create_password_reset_table和create_customer_table(我写了这个文件)。我需要在我的数据库中创建一个名为customer的表,其中包含一些列:
Schema::create('customers', function (Blueprint $table) {
$table->increments('id');
$table->string('first_name');
$table->string('last_name');
$table->boolean('azienda');
$table->string('iva');
$table->string('ds');
$table->boolean('fatres');
$table->string('cf');
$table->string('mail');
$table->string('telefono');
$table->integer('sponsor');
$table->string('indinst');
$table->string('civinst');
$table->string('cityInst');
$table->string('capinst');
$table->string('provinst');
$table->string('indf');
$table->string('civf');
$table->string('capf');
$table->string('provf');
$table->string('cityFatt');
$table->timestamps();
});
Run Code Online (Sandbox Code Playgroud)
如何完成迁移并创建表?谢谢你的答案!