【发布时间】:2017-12-21 20:07:49
【问题描述】:
我在创建数据库表时遇到问题。
首先我创建模型:
php artisan make:model Company -m
其次我更新迁移公司文件,添加我需要的列
第三,我要去phpMyAdmin创建一个名为test的新数据库
第四次我运行命令php artisan migrate 或php artisan migrate:install 并出现下一个错误:
[Illuminate\Database\QueryException]SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) (SQL: select * from information_schema.tables where table_schema = test and table_name = migrations)
[PDOException]SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)
在database/config.php我将mysql驱动编辑成这样:
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'test'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', 'pass'),
'charset' => 'utf8',
'collation' => 'utf8_general_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],
还有.env file:
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=test
DB_USERNAME=root
DB_PASSWORD=pass
我还尝试使用 php artisan config:clear 清理缓存。
有人可以帮助我吗?我不明白这是什么问题。
谢谢
【问题讨论】:
-
重启你的服务器再试一次
-
您没有密码来登录 phpmyadmin。删除密码,在 env 文件中保持空白
-
@Exprator phpmyadmin 与它无关,顺便说一句,mysql 配置为使用该用户的密码。这可能是错误的
-
这是我必须输入的mysql密码。 @Exprator
-
@Md.Abutaleb ,我已经这样做了,但不起作用!
标签: php mysql laravel phpmyadmin laravel-migrations