且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

SQLSTATE [HY000] [1045]用户'root'@'localhost'的访问被拒绝(使用密码:是)symfony2

更新时间:2021-08-04 21:22:32

这是由于您的mysql配置所致. 根据此错误,您试图以用户"root"连接到数据库名为"sgce"的数据库主机"localhost",而没有被授予访问权限.

This is due to your mysql configuration. According to this error you are trying to connect with the user 'root' to the database host 'localhost' on a database namend 'sgce' without being granted access rights.

假设您没有配置mysql实例.以root用户身份登录并登录到以下站点:

Presuming you did not configure your mysql instance. Log in as root user and to the folloing:

CREATE DATABASE sgce;

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

还要在parameter.yml中添加您的database_port. 默认情况下,mysql侦听3306:

Also add your database_port in the parameters.yml. By default mysql listens on 3306:

database_port: 3306