Laravel不能在CentOS 7.2

问题描述:

连接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

检查DB_PASSWORD设置在.env文件。

错误信息说using password: NO这意味着连接到数据库时没有使用密码。