SQLSTATE [HY000] [1045]用户'root'@'localhost'的访问被拒绝(使用密码:是)symfony2 [英] SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) symfony2
问题描述
当我尝试登录时出现错误:
When I try to login I get an error:
SQLSTATE [HY000] [1045]用户'root'@'localhost'的访问被拒绝(使用密码:是)
parametrs.yml:
parametrs.yml:
此文件是在Composer安装过程中自动生成的
This file is auto-generated during the composer install
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
My OS is 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
推荐答案
这是由于您的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
这篇关于SQLSTATE [HY000] [1045]用户'root'@'localhost'的访问被拒绝(使用密码:是)symfony2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!