Laravel不会在MAMP上重新加载.env文件

高个子乔纳森

我最近从使用内置的Apache2和Mac上的PHP安装切换到了最新版本的MAMP(3.5),并将所有项目都移到了htdocs文件夹中。更新到新的MySQL信息后,除了Laravel项目外,其他一切都正常。尝试访问使用MySQL的任何内容时,出现此错误

PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'cumc'@'localhost' (using password: YES)

新的.env文件在数据库信息中看起来像这样。

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=cumc
DB_USERNAME=root
DB_PASSWORD=root

因此,通过该错误,似乎正在缓存某些内容,但是我已经运行了所有可以找到的cache:clear命令,重新启动了MAMP,我的Mac,并尝试了我能想到的一切。即使app/database.php使用新的详细信息更改了,并更改了.env的名称,它也不会加载,并且仍然显示错误。

这是config/database.php文件

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | PDO Fetch Style
    |--------------------------------------------------------------------------
    |
    | By default, database results will be returned as instances of the PHP
    | stdClass object; however, you may desire to retrieve records in an
    | array format for simplicity. Here you can tweak the fetch style.
    |
    */

    'fetch' => PDO::FETCH_CLASS,

    /*
    |--------------------------------------------------------------------------
    | Default Database Connection Name
    |--------------------------------------------------------------------------
    |
    | Here you may specify which of the database connections below you wish
    | to use as your default connection for all database work. Of course
    | you may use many connections at once using the Database library.
    |
    */

    'default' => env('DB_CONNECTION', 'mysql'),

    /*
    |--------------------------------------------------------------------------
    | Database Connections
    |--------------------------------------------------------------------------
    |
    | Here are each of the database connections setup for your application.
    | Of course, examples of configuring each database platform that is
    | supported by Laravel is shown below to make development simple.
    |
    |
    | All database work in Laravel is done through the PHP PDO facilities
    | so make sure you have the driver for your particular database of
    | choice installed on your machine before you begin development.
    |
    */

    'connections' => [

        'sqlite' => [
            'driver' => 'sqlite',
            'database' => env('DB_DATABASE', database_path('database.sqlite')),
            'prefix' => '',
        ],

        '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' => false,
            'engine' => null,
        ],

        'pgsql' => [
            'driver' => 'pgsql',
            'host' => env('DB_HOST', 'localhost'),
            'port' => env('DB_PORT', '5432'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'charset' => 'utf8',
            'prefix' => '',
            'schema' => 'public',
        ],

    ],

    /*
    |--------------------------------------------------------------------------
    | Migration Repository Table
    |--------------------------------------------------------------------------
    |
    | This table keeps track of all the migrations that have already run for
    | your application. Using this information, we can determine which of
    | the migrations on disk haven't actually been run in the database.
    |
    */

    'migrations' => 'migrations',

    /*
    |--------------------------------------------------------------------------
    | Redis Databases
    |--------------------------------------------------------------------------
    |
    | Redis is an open source, fast, and advanced key-value store that also
    | provides a richer set of commands than typical key-value systems
    | such as APC or Memcached. Laravel makes it easy to dig right in.
    |
    */

    'redis' => [

        'cluster' => false,

        'default' => [
            'host' => env('REDIS_HOST', 'localhost'),
            'password' => env('REDIS_PASSWORD', null),
            'port' => env('REDIS_PORT', 6379),
            'database' => 0,
        ],

    ],

];
阿列克谢·梅泽宁(Alexey Mezenin)

运行php artisan config:clear,它将清除缓存的配置。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Laravel-加载不同的.env文件

Composer类映射自动加载不会在文件夹中加载新文件

在Makefile中加载.env文件

git不会在服务器上推送.env文件

Laravel 5基于.env.master加载env文件?

Rails 5不会在vendor / assets / javascripts目录中加载js文件

访问laravel .env文件

PHP Composer自动加载器不会在包含路径中加载文件

HTTParty不会在Ruby文件中加载

IntelliJ-Gradle-Kotlin-Micronaut-更改文件不会在“运行”时重新生成类

静态不会在Django中加载静态文件

图像不会在文件夹路径上移动

DomPDF不会在Laravel上下载AJAX请求的文件

为什么静态文件不会在Django Web应用程序中加载?

Keras ModelCheckpoint不会在Windows上保存任何文件

React Webpack捆绑器不会在文件更改时重新编译

laravel .env文件夹的数据库配置,托管在Mamp上

GEPlugin不会在VB.NET上加载KML文件

来自Javascript文件的方法将在IE中加载,但不会在Chrome中加载

Laravel 5.0.33加载错误的.env文件

从.csv文件读取的内容有时不会在页面加载时显示

React 样板不会在 index.html 中加载 js 文件

Django:对 css 文件的更改不会在 heroku 中加载

setup.py 构建不会在每个 C 源文件/增量构建上重新调用编译器

即使应用了 {% load static %},Django 静态文件也不会在块内容中加载

对代码的更改不会在 exe 文件上更新

Swagger Ui 不会在 asp.net mvc 上加载静态文件

nodejs 如何加载 .env 文件?

GAE Python 3:静态文件不会在本地主机上加载,但会在在线部署时加载