【问题标题】:Laravel can not connect mariaDB on CentOs 7.2Laravel 无法在 CentOs 7.2 上连接 mariaDB
【发布时间】: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)

我该怎么办?

【问题讨论】:

标签: php mysql laravel mariadb


【解决方案1】:

.env 文件中检查您的DB_PASSWORD 设置。

错误信息说using password: NO表示连接db时没有使用密码。

【讨论】:

    猜你喜欢
    • 2023-04-02
    • 2017-09-03
    • 1970-01-01
    • 1970-01-01
    • 2015-10-13
    • 1970-01-01
    • 2015-03-01
    • 2023-03-16
    • 2021-04-12
    相关资源
    最近更新 更多