duanchijie2323 2014-08-26 20:56
浏览 58
已采纳

Laravel 4 database.php无法访问DB

I have a laravel4 app working on my work computer. I recentley download the files via svn onto my home machine and when I attempt to open the project in the browser I get the following error:

ErrorException (E_UNKNOWN)

SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) (View: C:\wamp\www\xzy.tld\app\views\layout.blade.php) (View: C:\wamp\www\xyz.tld\app\views\layout.blade.php)

This is my database.php file:

'mysql' => array(
            'driver'    => 'mysql',
            'host'      => 'localhost',
            'database'  => 'xyz',
            'username'  => 'root',
            'password'  => '',
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => '',
        ),

I know for a fact that my home machine does not require a password for mysql so I don't know why this is happening? Is there some sort of composer command I should run in order to update my project?

EDIT: Strangely if I navigate to the Connector.php class within the framework and var_dump the $config variable I get this:

array (size=9)
  'driver' => string 'mysql' (length=5)
  'host' => string '127.0.0.1' (length=9)
  'database' => string 'xyz' (length=10)
  'username' => string 'root' (length=4)
  'password' => string 'root' (length=4)
  'charset' => string 'utf8' (length=4)
  'collation' => string 'utf8_unicode_ci' (length=15)
  'prefix' => string '' (length=0)
  'name' => string 'mysql' (length=5)

I don't know where this information is coming from because in my database.php file I have password set to nothing. If I delete all contents of the database.php file I still get same error.

  • 写回答

1条回答 默认 最新

  • duanchandun1860 2014-08-26 22:21
    关注

    Sounds like you're reading from the wrong configuration file. Check the credentials in both

    app/config/local/database.php
    

    and

    app/local/database.php
    

    It may be whatever means you'r to identify the local environment on one machine don't work on the second machine, and Laravel's reading from different files.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀