从 controller access 数据库失败,但能从 migration 创建表,从 aritisan tinker 操作数据。求助
背景
我将laravel连到了本地的xampp的mysql数据库。migartion能创建表,tinker能用model操作数据。
问题
但是当从controller连接数据库,得到下面的错误信息:
PDOException in Connector.php line 55:
SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: NO)
能想到的区别就是migration 和tinker都是从cli里面操作的,controller接受的是http request。不过连数据库都是一样机制的吧,不太明白为什么会有问题。求教!
推荐文章: