Laravel SQLSTATE[HY000] [2002] Connection refused

前端 未结 10 1374
情深已故
情深已故 2020-12-18 20:44

so I want to deploy my existing laravel porject into my digitalocean vps I user this tut and I upload my site successfully

also my env file is

APP_E         


        
相关标签:
10条回答
  • 2020-12-18 21:29

    In your .env file, change DB_HOST from 127.0.0.1 to localhost

    0 讨论(0)
  • 2020-12-18 21:32

    Put string:

    DB_SOCKET=/Applications/MAMP/tmp/mysql/mysql.sock
    

    after DB_PASSWORD=

    It works for MAMP. Set your path to mysql.sock

    0 讨论(0)
  • 2020-12-18 21:33

    Before you do changes as per instructed above,

    1. check if your database server running or not. If you are using command prompt, running mysql.server status or mysqld status shall show the database status.
    2. If the database is running, check if the dbuser is allow to connect from '%' or 'localhost' or '127.0.0.1'. If not, just grant the user access from '%'
    3. If you have done 1 and 2 and still can't connect, see if the db user is allow to access the schema. If not, grant access to the schema
    4. If you reach here and still got the same error, try to restart you web server.
    0 讨论(0)
  • 2020-12-18 21:41

    After long hours this worked for me:

    Changing the port in php My Admin previously 8889

    APP_NAME=laravel
    APP_ENV=local
    APP_KEY= YOUR KEY
    APP_DEBUG=true
    APP_URL=127.0.0.1
    
    LOG_CHANNEL=stack
    
    DB_CONNECTION=mysql
    DB_HOST=127.0.0.1
    DB_PORT=3306
    DB_SOCKET=/Applications/MAMP/tmp/mysql/mysql.sock
    

    and then

    php artisan cache:clear
    php artisan route:clear
    php artisan config:clear
    php artisan view:clear
    
    0 讨论(0)
提交回复
热议问题