mysql – 使用doctrine,Symfony 4创建数据库时拒绝访问
作者:互联网
我创建了一个新的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
尝试了一切,似乎没有任何工作.任何帮助将不胜感激.
解决方法:
参考这个similar issue
问题的可能原因:
>整理数据库
> mysql凭据无效
标签:symfony4,mysql,symfony,doctrine 来源: https://codeday.me/bug/20190910/1799266.html