简体   繁体   English

Sylius数据库凭证未更新

[英]Sylius Database Credentials Not Updating

I'm new to Sylius, and am configuring a site for the first time on MAMP Pro. 我是Sylius的新手,并且是第一次在MAMP Pro上配置站点。 I've installed Sylius via Composer, but realized that the database credentials I provided during install were not correct. 我已经通过Composer安装了Sylius,但是意识到我在安装过程中提供的数据库凭据不正确。 After this, I went into app/config/parameters.yml as per the documentation, and updated the following credentials: 之后,我根据文档进入了app / config / parameters.yml ,并更新了以下凭据:

database_driver: pdo_mysql
database_host: localhost
database_port: null
database_name: mydb
database_user: root
database_password: root

What's happening is every time I try to access the site, it throws a 500 error. 发生的事情是每次我尝试访问该网站时,都会引发500错误。 Upon checking my log, each time I try to access it, I get an error about access being denied to the DB: 检查日志后,每次尝试访问日志时,都会收到有关拒绝访问数据库的错误:

[15-Aug-2016 13:49:34 America/New_York] PHP Fatal error:  Uncaught PDOException: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) in vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:43

The strange thing is the error log also shows this: 奇怪的是错误日志也显示了这一点:

vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php(41): Doctrine\DBAL\Driver\PDOConnection->__construct('mysql:host=127....', 'root', 'secret', Array)

These are the old credentials (notice the password 'secret' instead of 'root', and the host '127.0.0.1' instead of 'localhost'. It appears that despite updating my parameters.yml with the correct credentials, Sylius won't stop trying to connect with the original credentials I used during setup. Is there another file that this could be stored in that's not mentioned in the documentation? Could it be caching the old credentials, and in need of some clearing? I'm at a loss for what's happening here. 这些是旧的凭据(请注意,密码为“ secret”而不是“ root”,而主机名为“ 127.0.0.1”而不是“ localhost”。尽管使用正确的凭据更新了我的parameter.yml ,但Sylius不会停止尝试与我在设置过程中使用的原始凭据建立连接。是否有另一个文件可以存储在文档中未提及的文件中?它是否可以缓存旧的凭据,并且需要一些清除?对于这里发生的事情感到损失。

EDIT : 编辑

I've also tried updating app/config/parameters.yml.dist with the proper credentials, to no effect. 我也尝试使用适当的凭据更新app / config / parameters.yml.dist ,但没有任何效果。

EDIT 2 : 编辑2

I've done an entire search of the project for the name of my old database, and have updated each instance to the new database name. 我已经在整个项目中搜索了旧数据库的名称,并将每个实例更新为新的数据库名称。 There are no files that reference the old DB name. 没有文件引用旧的数据库名称。 Then I try and run: 然后,我尝试运行:

php app/console cache:clear --env=dev --no-debug

and it throws errors: 并引发错误:

[Doctrine\DBAL\Driver\PDOException]                                              

SQLSTATE[08006] [7] FATAL: database "old_database_name" does not exist SQLSTATE [08006] [7]严重:数据库“ old_database_name”不存在

despite old_database_name not being referenced in any file. 尽管在任何文件中都未引用old_database_name。 Then if I do a search for old_database_name AFTER running the cache clear, it overwrites my new database name in app/cache/de_/ap_DevProjectContainer.php with the old name again, every time. 然后,如果我在运行清除缓存后搜索old_database_name,则每次都会用旧名称覆盖app / cache / de_ / ap_DevProjectContainer.php中的新数据库名称。 I can't even figure out where it's getting the old database name from, after I overwrite every instance of it. 在覆盖每个数据库实例之后,我什至不知道它是从哪里获得旧数据库名称的。 What's happening here?? 这里发生了什么事??

The default Sylius configuration uses a different database for production and development. Sylius的默认配置使用其他数据库进行生产和开发。 In your case, this would be sylius from prod and for the dev environment _dev is appended to the datbase name. 在您的情况下,这将是prod中的sylius ,对于开发环境_dev将附加到_dev名称中。 This is expected behavior and not a bug. 这是预期的行为,而不是错误。

You can find the configuration at the end of app/config/config_dev.yml . 您可以在app/config/config_dev.yml的末尾找到配置。 If you remove the following lines, both environments use the same database. 如果删除以下行,则两种环境都使用相同的数据库。

doctrine:
    dbal:
        dbname: %sylius.database.name%_dev

https://github.com/Sylius/Sylius/issues/2362 https://github.com/Sylius/Sylius/issues/2362

In this case, old_database_name was the same as my new database name, only it contained the suffix '_dev'. 在这种情况下,old_database_name与我的新数据库名称相同,只是它包含后缀'_dev'。 I've now realized that this is because I'm in the dev environment. 我现在意识到这是因为我处于开发环境中。 There doesn't seem to be any easy way I've found to remove this suffix, so I'm just going to roll with it. 我发现删除此后缀似乎没有任何简便的方法,因此我将继续介绍它。 Would still like an answer on how to remove this, but for now I've answered my own question. 仍然想知道如何删除它的答案,但是到目前为止,我已经回答了自己的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM