【发布时间】:2017-04-20 07:16:02
【问题描述】:
How to configure MariaDB in Laravel 5?
上面的帖子提到将端口3306更改为3307,我试过了,但还是不行。
我在本地windows上写代码,端口也是3306,应用可以运行,我把应用复制到云主机,操作系统是CentOs 7.2,出现错误。
我正在使用 Laravel 5.3 和 mariaDB 10.2。
.env文件是这样的:
DB_USERNAME=root
DB_PASSWORD=123456
config/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,
],
我可以通过终端访问它:
# mysql -uroot -p123456;
MariaDB [(none)]>
运行php artisan migrate时,出现错误:
[PDOException]
SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: NO)
我该怎么办?
【问题讨论】:
-
请edit您的问题并添加
config/database.php的相关部分。 -
@Chris 我已经添加了
config/database.php的部分。 -
这看起来像您的确切问题。 laracasts.com/discuss/channels/general-discussion/… 恰好是 google 上的第一个结果
-
你想在
.env中连接什么数据库?里面应该有DB_DATABASE的字样。