MAMP自定义模块上的Magento安装失败“未知数据库'magento'”

时间:2019-03-22 20:54:01

标签: php magento magento2

我已经创建了一个自定义模块,但是当我运行php bin/magento setup:upgrade时,它失败并返回SQLSTATE [HY000] [1049]未知数据库'magento'。

我尝试了其他stackover flow解决方案,但没有成功。而且我已经卸载并重新安装了magento实例。

enter image description here

/app/etc.php

<?php
return [
    'backend' => [
        'frontName' => 'admin'
    ],
    'crypt' => [
        'key' => 'e6e76a3bc072a8ccf6c12282b78db401'
    ],
    'db' => [
        'table_prefix' => '',
        'connection' => [
            'default' => [
                'host' => 'localhost',
                'dbname' => 'magento',
                'username' => 'root',
                'password' => 'root',
                'active' => '1'
            ]
        ]
    ],
    'resource' => [
        'default_setup' => [
            'connection' => 'default'
        ]
    ],
    'x-frame-options' => 'SAMEORIGIN',
    'MAGE_MODE' => 'default',
    'session' => [
        'save' => 'files'
    ],
    'cache_types' => [
        'config' => 1,
        'layout' => 1,
        'block_html' => 1,
        'collections' => 1,
        'reflection' => 1,
        'db_ddl' => 1,
        'compiled_config' => 1,
        'eav' => 1,
        'customer_notification' => 1,
        'config_integration' => 1,
        'config_integration_api' => 1,
        'full_page' => 1,
        'config_webservice' => 1,
        'translate' => 1,
        'vertex' => 1
    ],
    'install' => [
        'date' => 'Fri, 22 Mar 2019 20:36:14 +0000'
    ]
];

2 个答案:

答案 0 :(得分:1)

您能正常使用吗?

从我可以看到您的.env只是为mysql引用了错误的端口号。

尝试一下(将主机更改为localhost:8889):

'default' => [
    'host' => 'localhost:8889',
    'dbname' => 'magento',
    'username' => 'root',
    'password' => 'root',
    'active' => '1'
]

答案 1 :(得分:0)

我最终通过显式调用我的PHP版本的路径来调用此命令:/Applications/MAMP/bin/php/php7.2.1/bin/php bin/magento setup:upgrade