I am trying to upload website on cpanel. The following error is encountering
我正在尝试在cpanel上传网站。遇到以下错误
PDOException in Connector.php line 47: SQLSTATE[HY000] [1045] Access denied for user 'hassan'@'localhost' (using password: YES)
Connector.php第47行中的PDOException:SQLSTATE [HY000] [1045]用户'hassan'@'localhost'的访问被拒绝(使用密码:YES)
My .env file contains:
我的.env文件包含:
APP_ENV=local
APP_DEBUG=true
APP_KEY=4ZuW70AMILLsnvHkTJ1yraRoGqmx4Dzg
DB_HOST=localhost
DB_DATABASE=campaign
DB_USERNAME=hassan
DB_PASSWORD=password
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
and config/database.php as
和config / database.php一样
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'campaign'),
'username' => env('DB_USERNAME', 'hassan'),
'password' => env('DB_PASSWORD', 'China125'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,]
What might be wrong with it?
它可能有什么问题?
1 个解决方案
#1
The second paramater of env
function contains a default value, which is used if the needed constant is not found.
env函数的第二个参数包含一个默认值,如果找不到所需的常量,则使用该值。
In your case, you specify constant DB_PASSWORD
and use value password
.
在您的情况下,您指定常量DB_PASSWORD并使用值密码。
Did you intend to use value China125
?
你打算用价值中国125吗?
Either remove that constant completely from .env
file in order to use your default, or set it to China125
:
要么从.env文件中完全删除该常量以使用您的默认值,或将其设置为China125:
DB_HOST=localhost
DB_DATABASE=campaign
DB_USERNAME=hassan
DB_PASSWORD=China125
#1
The second paramater of env
function contains a default value, which is used if the needed constant is not found.
env函数的第二个参数包含一个默认值,如果找不到所需的常量,则使用该值。
In your case, you specify constant DB_PASSWORD
and use value password
.
在您的情况下,您指定常量DB_PASSWORD并使用值密码。
Did you intend to use value China125
?
你打算用价值中国125吗?
Either remove that constant completely from .env
file in order to use your default, or set it to China125
:
要么从.env文件中完全删除该常量以使用您的默认值,或将其设置为China125:
DB_HOST=localhost
DB_DATABASE=campaign
DB_USERNAME=hassan
DB_PASSWORD=China125