【发布时间】:2020-08-31 04:27:06
【问题描述】:
我第一次尝试将我的 laravel 项目与我的数据库 mysql 连接起来,但越来越不可能了。我有 ubuntu 20。每当我尝试迁移(php artisan migrate)时,我都会得到这个:
Illuminate\Database\QueryException
SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: NO) (SQL: select * from information_schema.tables where table_schema = laravel and table_name = migrations and table_type = 'BASE TABLE')
at vendor/laravel/framework/src/Illuminate/Database/Connection.php:671
667| // If an exception occurs when attempting to run a query, we'll format the error
668| // message to include the bindings with SQL, which will make this exception a
669| // lot more helpful to the developer instead of just the database's errors.
670| catch (Exception $e) {
> 671| throw new QueryException(
672| $query, $this->prepareBindings($bindings), $e
673| );
674| }
675|
+34 vendor frames
35 artisan:37
Illuminate\Foundation\Console\Kernel::handle()
我尝试了一切...我认为我的 .ENV 文件是正确的:
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=laravel1
DB_USERNAME=root
DB_PASSWORD=1234
我有一个用户“root”并传递“1234”。在控制台中它工作得很好-> sudo mysql -u root -p(然后是 1234)... 我还在 phpmyadmin 中创建了数据库 laravel1,所以没关系... 帮助
【问题讨论】: