doutangqi4444 2015-07-11 16:35
浏览 54

sqlstate [28000] [1045]访问被拒绝用户'用户'@'localhost'(使用密码:否)laravel(在laravel中部署后)

I am working on a project using laravel and deploy it to openshift via git.

When I worked on my local computer, everything is alright. Then I tried to deploy my project in openshift. After succeed configure and deploy my app in the openshift, then I run the application in my local computer but the configuration didn't work. Below is the error message:

PDOException in Connector.php line 47: SQLSTATE[28000] [1045] Access denied for user 'user'@'localhost' (using password: NO)

here's my database.php

'default' => 'mysql',
'connections' => [

    'mysql' => [
        'driver'    => 'mysql',
        'host'      => getenv('OPENSHIFT_MYSQL_DB_HOST'),
        'port'      => getenv('OPENSHIFT_MYSQL_DB_PORT'),
        'database'  => getenv('OPENSHIFT_APP_NAME'),
        'username'  => getenv('OPENSHIFT_MYSQL_DB_USERNAME'),
        'password'  => getenv('OPENSHIFT_MYSQL_DB_PASSWORD'),
        'charset'   => 'utf8',
        'collation' => 'utf8_unicode_ci',
        'prefix'    => '',
        'strict'    => false,
    ]
],

'migrations' => 'migrations',


'redis' => [

    'cluster' => false,

    'default' => [
        'host'     => '127.0.0.1',
        'port'     => 6379,
        'database' => 0,
    ],

],

and this is my .env

APP_ENV=local
APP_DEBUG=true
APP_KEY=5XfZXUrDIbmZkIqAgSdOPuYMzSub9DUv

DB_HOST=localhost
DB_DATABASE=dbname
DB_USERNAME=root
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

I am using laravel 5. I am sure that the problem is about the configuration. but I have no idea where should I change the configuration. I think Laravel should read a configuration in .env file for specific DB_HOST, Right?. How do I fix the configuration?

Thank you for advance!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 测距传感器数据手册i2c
    • ¥15 RPA正常跑,cmd输入cookies跑不出来
    • ¥15 求帮我调试一下freefem代码
    • ¥15 matlab代码解决,怎么运行
    • ¥15 R语言Rstudio突然无法启动
    • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
    • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
    • ¥15 用windows做服务的同志有吗
    • ¥60 求一个简单的网页(标签-安全|关键词-上传)
    • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法