SQLSTATE [HY000] [1045]用户'root'@'localhost'的访问被拒绝(使用密码:NO)(SQL:从"rooms"订单中按"order_by" asc选择*) [英] SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: NO) (SQL: select * from `rooms` order by `order_by` asc)

查看:125
本文介绍了SQLSTATE [HY000] [1045]用户'root'@'localhost'的访问被拒绝(使用密码:NO)(SQL:从"rooms"订单中按"order_by" asc选择*)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码在localhost上运行良好,但是当我将其上传到服务以下错误显示

my code run fine in localhost but when i uploaded it on the serve following error show

Illuminate \ Database \ QueryException(1045)SQLSTATE [HY000] [1045]用户'root'@'localhost'的访问被拒绝(使用密码:否)(SQL:从 rooms 中按*依次按 order_by asc选择*)以前的例外SQLSTATE [HY000] [1045]用户'root'@'localhost'的访问被拒绝(使用密码:否)(1045)

Illuminate \ Database \ QueryException (1045) SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: NO) (SQL: select * from rooms order by order_by asc) Previous exceptions SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: NO) (1045)

APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:tT9jGFWVeBX5uLy/CVZbs8k+RNGBpMyJ526xfRv3DKQ=
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=janatapa_shre
DB_USERNAME=janatapa_shre
DB_PASSWORD=Shre@123

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

尽管我更改了.env文件中的数据库名称,用户名和密码,但仍然显示拒绝用户'root'@'localhost'的访问(使用密码:否)"这是我的本地主机密码和用户名''

though i have changed the database name , user and password in .env file it still says "Access denied for user 'root'@'localhost' (using password: NO)" which was my localhost password and user name''

我什至无法清除缓存

当我尝试在服务器上使用以下代码

while i was try to use following code on server

php artisan cache:clear
php artisan config:clear
php artisan config:cache
php artisan view:clear

终端上显示以下错误

[在Connection.php第664行:

[In Connection.php line 664:

SQLSTATE [HY000] [1045]对用户'root'@'localhost'的访问被拒绝(使用pas
剑:否)(SQL:从 rooms 订单中按*按 order_by asc选择*)

SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using pas
sword: NO) (SQL: select * from rooms order by order_by asc)

在Connector.php第70行中:

In Connector.php line 70:

SQLSTATE [HY000] [1045]对用户'root'@'localhost'的访问被拒绝(使用pas
剑:否)] 1

SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using pas
sword: NO) ]1

推荐答案

我也遇到了这个问题,如果您的密码字符串包含#(例如Test123#)的功能",则一切正常,您的DB_USERNAME或DB_PASSWORD5.8或更高版本将#视为注释定界符,因此将您的密码重写为DB_PASSWORD ='Test123#'及其工作方式.它对我有用.

I also faced this issue, every thing is fine your DB_USERNAME or DB_PASSWORD, if you your password string contains # (for eg. Test123#) "feature"of 5.8 or above it treat # as comment delimiter, so rewrite your password as DB_PASSWORD='Test123#' and its works. it work for me.

这篇关于SQLSTATE [HY000] [1045]用户'root'@'localhost'的访问被拒绝(使用密码:NO)(SQL:从"rooms"订单中按"order_by" asc选择*)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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