【发布时间】:2021-12-03 13:51:58
【问题描述】:
我之前设置过 Laravel,但从未遇到过数据库未知问题。我正在尝试在新项目上安装默认的 Laravel 迁移。
我已经在我的服务器上创建了数据库。
我正在使用 MAMP Apache 端口:80 MYSQL 端口:3306
我的环境设置如下所示:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=thevinesa
DB_USERNAME=root
DB_PASSWORD=******
当我尝试使用 PHP artisan 迁移时;我收到一个数据库未知错误
SQLSTATE[HY000] [1049] Unknown database 'thevinesa' (SQL: select * from information_schema.tables where table_schema = thevinesa and table_name = migrations and table_type = 'BASE TABLE') at vendor/laravel/framework/src/Illuminate/Database/Connection.php:703
699▕ // If an exception occurs when attempting to run a query, we'll format the error
700▕ // message to include the bindings with SQL, which will make this exception a
701▕ // lot more helpful to the developer instead of just the database's errors.
702▕ catch (Exception $e) {
703▕ throw new QueryException(
704▕ $query, $this->prepareBindings($bindings), $e
705▕ );
706▕ }
707▕ }
+33 vendor frames
34 artisan:37
Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
我该如何解决这个错误
【问题讨论】:
-
您确定创建了
thevinesa数据库,即运行CREATE DATABASE thevinesa;? -
永远不要共享您的密码,即使它只是一个本地主机数据库。您确定以区分大小写的方式正确输入了数据库吗?端口是否正确?用户名和密码是否正确?可以通过 CLI 连接到数据库吗?
-
使用 sequal pro,我可以连接到数据库,但是通过 laravel,我无法
-
@ThandoHlophe 你能在这里查看我的答案和发布错误日志,以便我提供帮助。
标签: php laravel laravel-migrations