2017-01-09 73 views
0

我正在使用laravel 5.3LAMP中的Laravel 5.3 - 遷移不起作用

最近我在Ubuntu 14.04上安裝了我的項目,並將我的項目移動到了LAMP,之後它在WAMP之前。

.env文件如下:

APP_ENV=local 
APP_DEBUG=true 
APP_KEY=somebase64key 
DB_HOST=localhost 
DB_DATABASE="local.d2d.com" 
DB_USERNAME=d2d 
DB_PASSWORD= 
CACHE_DRIVER=file 
SESSION_DRIVER=file 

是的,我有用戶d2d並在mysql數據庫local.d2d.com所有權限。

config/database.php是:

<?php 

return [ 
    'fetch' => PDO::FETCH_CLASS, 
    'default' => 'mysql', 
    'connections' => [ 
     'mysql' => [ 
      'driver' => 'mysql', 
      'host'  => env('DB_HOST'), 
      'database' => env('DB_DATABASE'), 
      'username' => env('DB_USERNAME'), 
      'password' => env('DB_PASSWORD'), 
      'charset' => 'utf8', 
      'collation' => 'utf8_unicode_ci', 
      'prefix' => '', 
      'strict' => false, 
     ] 
    ], 

    'migrations' => 'migrations', 
    'redis' => [ 
     'cluster' => false, 
     'default' => [ 
      'host'  => '127.0.0.1', 
      'port'  => 6379, 
      'database' => 0, 
     ] 
    ] 
]; 

在運行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 = local.d2d.com and table_name = migrations)

[Doctrine\DBAL\Driver\PDOException] SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: NO) [PDOException] SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: NO)

你可以看到我不使用root用戶在任何地方我仍面臨這個問題。即使在連接錯誤,你可能會發現數據庫是information_schema而不是local.d2d.com

是的,我已經跑php artisan config:clearphp artisan cache:clearphp artisan view:clearphp artisan clear-compiledphp artisan optimize多次。

誰能幫助?

+0

沒有您重新啓動laravel服務器?如果別的停止當前的服務器,再次啓動並運行配置和緩存清除命令,讓我知道。 –

+0

@ArunCode我已經運行了'''sudo service apache2 restart'''並清除了配置以及緩存,仍然存在相同的問題。 – Jimi

+0

@ R.Mazarei我也​​試過了,但它似乎不工作。 – Jimi

回答

0

更改config/database.php這樣的:

<?php 
    ... 
    'mysql' => [ 
     ... 
     'host'  => env('DB_HOST', 'localhost'), 
     'database' => env('DB_DATABASE', 'example'), 
     'username' => env('DB_USERNAME', 'root'), 
     'password' => env('DB_PASSWORD', 'root'), 
     ... 
    ], 
    ... 

然後

php artisan cache:clear 
php artisan config:cache