Laravel 6.4.1 SQLSTATE[HY000] [2002] Connection refused

前端 未结 10 2098
隐瞒了意图╮
隐瞒了意图╮ 2021-02-15 14:32

I am new in Laravel development. I have updated Xampp to 7.3.11 on my Mac Mojave 10.14.6. In Laravel project when I hit php artisan migrate command I got following error.

<
相关标签:
10条回答
  • 2021-02-15 15:20

    Try this conf in .env (i'm using Laravel v7.0), it's working for me :

    DB_CONNECTION=mysql
    DB_HOST=mysql
    DB_PORT=3306
    DB_DATABASE=laravel
    DB_USERNAME=root
    DB_PASSWORD=root
    
    0 讨论(0)
  • 2021-02-15 15:25

    I had the same problem and when I applied the following operations, the problem was solved.

        php artisan key:generate
        php artisan cache:clear
        php artisan route:clear
        php artisan config:clear 
        php artisan view:clear 
    
    0 讨论(0)
  • 2021-02-15 15:28

    Try out doing

    php artisan config:cache

    then on your .env file specify your database and your port

    DB_CONNECTION=mysql
    DB_HOST=127.0.0.1
    DB_PORT=3306
    DB_DATABASE= YOUR_DATABASE_NAME
    DB_USERNAME=root
    DB_PASSWORD=
    

    then run your mysql server and run

    php artisan migrate

    Note: Make sure your Xammp server is perfectly fine & have already started mysql (using apache server or any server you are using) and also make sure you already created your database before running php artisan migrate Hope it works for you

    0 讨论(0)
  • 2021-02-15 15:31

    In most cases it's an issue with the port configuration. You need to check which port your server is running on. Then you have to edit the .env file of your project. For instance if you are using mamp the port should be changed to 8889 instead of the default 3606 for laravel. The same applies to laravel 8.

    0 讨论(0)
提交回复
热议问题