Laravel 4 database.php无法访问DB

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.

我的工作计算机上有一个 laravel4 code>应用程序。 我最近通过 svn code>将文件下载到我的家用机器上,当我尝试在浏览器中打开项目时,我收到以下错误: p>

  ErrorException  (E_UNKNOWN)
 
SQLSTATE [HY000] [1045]用户'root'@'localhost'拒绝访问(使用密码:YES)(查看:C:\ wamp \ www \ xzy.tld \ app \ views \ layout。  blade.php)(查看:C:\ wamp \ www \ xyz.tld \ app \ views \ layout.blade.php)
  code>  pre> 
 
 

这是我的 database.php code>文件: p>

 'mysql'=> 数组(
'driver'=>'mysql',
'host'=>'localhost',
'数据库'=>'xyz',
'用户名'=>'root',  
'password'=>'',
'charset'=>'utf8',
'collat​​ion'=>'utf8_unicode_ci',
'前缀'=>'',
),  
  code>  pre> 
 
 

我知道我的家用机器不需要 mysql code>的密码,所以我不知道为什么会发生这种情况 ? 是否有某种 composer code>命令我应该运行以更新我的项目? p>

编辑:奇怪的是,如果我导航到框架内的 Connector.php code>类和 var_dump code> $ config code> variable我得到这个: p>

  array(size = 9)
'driver'=>  string'mysql'(length = 5)
'host'=> 字符串'127.0.0.1'(长度= 9)
'数据库'=> 字符串'xyz'(长度= 10)
'用户名'=> 字符串'root'(长度= 4)
'密码'=>  string'root'(length = 4)
'charset'=> 字符串'utf8'(长度= 4)
'整理'=>  string'utf8_unicode_ci'(长度= 15)
'前缀'=>  string''(length = 0)
'name'=>  string'mysql'(length = 5)
  code>  pre> 
 
 

我不知道这些信息的来源,因为在我的 database.php code>中 文件我的密码设置为空。 如果我删除 database.php code>文件的所有内容,我仍然会收到同样的错误。 p> div>

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.