【发布时间】:2018-11-16 07:03:20
【问题描述】:
我创建了一个新的 Symfony 4 项目并想创建一个新的数据库。我正在关注this tutorial,但无法正常工作。运行时
php bin/console doctrine:database:create
我总是遇到同样的错误:
In AbstractMySQLDriver.php line 112:
An exception occurred in driver: SQLSTATE[HY000] [1045] Access denied for user 'user_1'@'localhost' (using password: YES)
In PDOConnection.php line 50:
SQLSTATE[HY000] [1045] Access denied for user 'user_1'@'localhost' (using password: YES)
In PDOConnection.php line 46:
SQLSTATE[HY000] [1045] Access denied for user 'user_1'@'localhost' (using password: YES)
按照教程,我在 .env 文件中配置了数据库 url,但它似乎没有改变任何东西。
DATABASE_URL=mysql://user_1:secretPassword@127.0.0.1:3306/db_name
我的 config/packages/doctrine.yaml 配置:
parameters:
env(DATABASE_URL): ''
doctrine:
dbal:
# configure these for your database server
driver: 'pdo_mysql'
server_version: '5.7'
charset: utf8mb4
default_table_options:
charset: utf8mb4
collate: utf8mb4_unicode_ci
url: '%env(resolve:DATABASE_URL)%'
orm:
auto_generate_proxy_classes: '%kernel.debug%'
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
mappings:
App:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: App
尝试了一切,但似乎没有任何效果。任何帮助将不胜感激。
【问题讨论】:
-
您可以使用stackoverflow.com/q/10299148/2123530进行故障排除
标签: mysql symfony doctrine symfony4