有谁能帮我在PHP laravel中获得迁移

x759pob2  于 2023-03-04  发布在  PHP
关注(0)|答案(1)|浏览(147)

我试图在新创建的laravel项目中迁移我的表,并得到这个错误,但所有的容器都运行良好。

Illuminate\Database\QueryException 

SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo for mysql failed: nodename nor servname provided, or not known (Connection: mysql, SQL: select * from information_schema.tables where table_schema = example_app and table_name = migrations and table_type = 'BASE TABLE')at vendor/laravel/framework/src/Illuminate/Database/Connection.php:760
756▕         // If an exception occurs when attempting to run a query, we'll format the error
757▕         // message to include the bindings with SQL, which will make this exception a
758▕         // lot more helpful to the developer instead of just the database's errors.
759▕         catch (Exception $e) {
➜ 760▕             throw new QueryException(
761▕                 $this->getName(), $query, $this->prepareBindings($bindings), $e
762▕             );
763▕         }
764▕     }

  +47 vendor frames 

48  artisan:35
  

Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

我尝试将我的表从本地迁移到管理员。

8yparm6h

8yparm6h1#

错误消息指出无法连接到数据库。
config/database.php中,检查

  1. host
  2. port
  3. database
  4. username
  5. password
    如果你从.env设置它,检查值是否正确。如果正确,运行下面的代码来清除配置缓存。
php artisan optimize

相关问题