2016-12-05 73 views
0
連接MariaDB的

How to configure MariaDB in Laravel 5?Laravel不能在CentOS 7.2

線程上面提到的,改變端口3306到3307,我試了,但還是不行。

我在本地Windows上編寫我的代碼,端口也是3306,並且應用程序可以運行,我將應用程序複製到雲主機,OS是CentOs 7.2,出現錯誤。

而我正在使用Laravel 5.3和mariaDB 10.2

.env文件是這樣的:

# mysql -uroot -p123456; 
MariaDB [(none)]> 

當運行php artisan migrate,有:

DB_USERNAME=root 
DB_PASSWORD=123456 

配置/ database.php中

'mysql' => [ 
    'driver' => 'mysql', 
    'host' => env('DB_HOST', 'localhost'), 
    'port' => env('DB_PORT', '3306'), 
    'database' => env('DB_DATABASE', 'forge'), 
    'username' => env('DB_USERNAME', 'forge'), 
    'password' => env('DB_PASSWORD', ''), 
    'charset' => 'utf8', 
    'collation' => 'utf8_unicode_ci', 
    'prefix' => '', 
    'strict' => true, 
    'engine' => null, 
], 

我可以通過終端訪問它錯誤:

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

我該怎麼辦?

+0

請編輯您的問題並添加'config/database.php'的相關部分。 – Chris

+0

@Chris我添加了「config/database.php」的一部分。 – zwl1619

+0

這看起來像你的確切問題。 https://laracasts.com/discuss/channels/general-discussion/setting-up-mariadb-with-laravel-5碰巧這是Google上的第一個結果 – bassxzero

回答

0

檢查DB_PASSWORD設置在.env文件。

錯誤信息說using password: NO這意味着連接到數據庫時沒有使用密碼。