2 pièce(s) jointe(s)
SQLSTATE[HY000] [2002] Connection refused]
Bonjour,
Je suis débutant avec laravel, veuillez donc m'excuser pour cette question.
Je suis occupé à suivre un tuto afin de tester AJAX avec Laravel : https://appdividend.com/2018/02/07/l...rial-example/#
J'ai donc créé mon projet :
Code:
composer create-project laravel/laravel laravel-ajax --prefer-dist
J'ai appliqué cette commande :
Code:
php artisan make:migration create_groceries_table
J'ai modifié la méthode up :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| public function up()
{
Schema::create('groceries', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('type');
$table->integer('price');
$table->timestamps();
});
} |
Par contre, quand je lance cette commande dans le terminal :
Code:
php artisan migrate
J'obtiens cette erreur :
Citation:
Illuminate\Database\QueryException : SQLSTATE[HY000] [2002] Connection refused (SQL: select * from information_schema.tables where table_schema = groceries and table_name = migrations)
at /Applications/MAMP/htdocs/laravel-ajax/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664
660| // If an exception occurs when attempting to run a query, we'll format the error
661| // message to include the bindings with SQL, which will make this exception a
662| // lot more helpful to the developer instead of just the database's errors.
663| catch (Exception $e) {
664| throw new QueryException(
665| $query, $this->prepareBindings($bindings), $e
666| );
667| }
668|
Exception trace:
1 PDOException::("SQLSTATE[HY000] [2002] Connection refused")
/Applications/MAMP/htdocs/laravel-ajax/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:68
2 PDO::__construct("mysql:host=127.0.0.1;port=8889;dbname=groceries", "root", "root", [])
/Applications/MAMP/htdocs/laravel-ajax/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:68
Please use the argument -v to see more details.
J'ai créé manuellement la base de données Groceries, je ne sais pas si devais le faire ?
Pièce jointe 371933
Je vous confirme pourtant que la bd est créée est a tous les privilèges pour localhost et 127.0.0.1
Voici le numéro du port de mysql :
Pièce jointe 371939
Et voici mon fichier .env :
Code:
1 2 3 4 5 6
| DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=8889
DB_DATABASE=groceries
DB_USERNAME=root
DB_PASSWORD=root |
Merci d'avance pour l'aide.
bee