当前位置: 首页 > 知识库问答 >
问题:

SQLSTATE[HY000][1045]拒绝用户“root”@“localhost”访问(使用密码:YES)symfony2

羊舌旭尧
2023-03-14
parameters:
    database_driver: pdo_mysql
    database_host: localhost
    database_port: null
    database_name: sgce
    database_user: root
    database_password: mikem
    mailer_transport: smtp
    mailer_host: 127.0.0.1
    mailer_user: null
    mailer_password: null
    locale: en
    secret: ThisTokenIsNotSoSecretChangeIt

我的操作系统是Debian

谢谢你的帮助。

[mysqld_safe]
socket      = /var/run/mysqld/mysqld.sock
nice        = 0

[mysqld]
#
# * Basic Settings
#
#skip-grant-tables
user        = mysql
pid-file    = /var/run/mysqld/mysqld.pid
socket      = /var/run/mysqld/mysqld.sock
port        = 3306
basedir     = /usr
datadir     = /var/lib/mysql
tmpdir      = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
#bind-address       = 127.0.0.1
bind-address        = 10.1.4.3

共有1个答案

子车凯泽
2023-03-14

这是由于您的mysql配置造成的。根据此错误,您试图与用户'root'连接到数据库名称'sgce'上的数据库主机'localhost'而未授予访问权限。

假设您没有配置mysql实例。以root用户身份登录到folloing:

CREATE DATABASE sgce;

CREATE USER 'root'@'localhost' IDENTIFIED BY 'mikem';
GRANT ALL PRIVILEGES ON sgce. * TO 'root'@'localhost';
FLUSH PRIVILEGES;

还要在parameters.yml中添加database_port。默认情况下,mysql监听3306:

database_port: 3306
 类似资料: