简体   繁体   中英

Sylius Database Credentials Not Updating

I'm new to Sylius, and am configuring a site for the first time on MAMP Pro. I've installed Sylius via Composer, but realized that the database credentials I provided during install were not correct. After this, I went into app/config/parameters.yml as per the documentation, and updated the following credentials:

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. 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.

EDIT :

I've also tried updating app/config/parameters.yml.dist with the proper credentials, to no effect.

EDIT 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

despite old_database_name not being referenced in any file. 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. 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. In your case, this would be sylius from prod and for the dev environment _dev is appended to the datbase name. This is expected behavior and not a bug.

You can find the configuration at the end of 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

In this case, old_database_name was the same as my new database name, only it contained the suffix '_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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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