首页 > 解决方案 > 如何修复 Laravel 8 - “SQLSTATE[HY000] [1049] 未知数据库”

问题描述

我正在尝试运行以下命令:

php artisan migrate

当我这样做时,我收到以下错误:

Illuminate\Database\QueryException

  SQLSTATE[HY000] [1049] Unknown database 'verified_db' (SQL: select * from information_schema.tables where table_schema = verified_db and table_name = migrations and table_type = 'BASE TABLE')

  at C:\Users\richa\Desktop\back-office\vendor\laravel\framework\src\Illuminate\Database\Connection.php:692
    688▕         // If an exception occurs when attempting to run a query, we'll format the error
    689▕         // message to include the bindings with SQL, which will make this exception a
    690▕         // lot more helpful to the developer instead of just the database's errors.
    691▕         catch (Exception $e) {
  ➜ 692▕             throw new QueryException(
    693▕                 $query, $this->prepareBindings($bindings), $e
    694▕             );
    695▕         }
    696▕     }

  1   C:\Users\richa\Desktop\back-office\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70
      PDOException::("SQLSTATE[HY000] [1049] Unknown database 'verified_db'")

  2   C:\Users\richa\Desktop\back-office\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70
      PDO::__construct()

我已经使用我的数据库凭据配置了 .env 文件。我希望有人可以帮助解决这个问题。

标签: mysqllaravelmigrate

解决方案


在 MySQL Workbench *在连接的服务器中创建一个新模式 ~set [Schema Name] = [DB_DATABASE]='your name' 运行命令:php artisan migrate

在 phpMyAdmin *create a Database ~set [Database Name] = [DB_DATABASE]='your name' 运行命令:php artisan migrate


推荐阅读