SQLSTATE [HY000] [1045]用户'root'@'localhost'的访问被拒绝(使用密码:NO). DB_HOST设置为localhost [英] SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: NO) . DB_HOST set to localhost

查看:1020
本文介绍了SQLSTATE [HY000] [1045]用户'root'@'localhost'的访问被拒绝(使用密码:NO). DB_HOST设置为localhost的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这个问题可能已经在stackOverflow中得到了答案. 但是我这里有不同的问题. 我将laravel项目从localhost移到了server.我已经完成了服务器中的每个步骤. 我可以查看服务器中的登录页面. 问题是,我无法与mysql服务器连接. 我的.env文件.

I know this question may have answers already in stackOverflow . But I have different issue here . I moved the laravel project from localhost to server . Which I have done every steps in server. I can able to view the login page in my server. The problem is, I can't able to connect with my mysql server . my .env file .

APP_NAME=Transport
APP_ENV=local
APP_KEY=base64:mrakeyidharhaikonsdf
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=transport_db
DB_USERNAME=root
DB_PASSWORD=mypass

我尝试将主机更改为127.0.0.1,还尝试放置服务器的ip.它没有帮助我. 我想念什么吗?

I tried to change the host to 127.0.0.1 and also tried to put my server's ip . It didn't helped me. Am I missing something ?

我的错误:

SQLSTATE [HY000] [1045]用户'root'@'localhost'的访问被拒绝(使用密码:否)(SQL:从users中选择count(*)作为聚合,其中email = user.email @ gmail.com)

SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: NO) (SQL: select count(*) as aggregate from users where email = user.email@gmail.com)

推荐答案

确保正确设置了数据库凭据和数据库主机:

Make sure your DB credential and DB Host is set correctly :

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE="your_database_name"
DB_USERNAME="put_db_user_name _here"
DB_PASSWORD="put_db_password_here_if_have_set"

如果您尚未设置任何数据库密码,请输入

If you have not set any db password the put

DB_PASSWORD=""

这篇关于SQLSTATE [HY000] [1045]用户'root'@'localhost'的访问被拒绝(使用密码:NO). DB_HOST设置为localhost的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆