I'm beginner on laravel. And i have encountered Connection error with mysql on laravel version 5.4.16

This is my route code to add tables into firstapp db

Route::get('/', function () 
{
    Schema::create('users', function($table)
    {
        $table->increments('id');
    });        
    return view('welcome');
});

And this is config\database.php file's code

'mysql' => [
    'driver' => 'mysql',
    'host' => env('DB_HOST', 'localhost'),
    'port' => env('DB_PORT', '3306'),
    'database' => env('DB_DATABASE', 'firstapp'),
    'username' => env('DB_USERNAME', 'root'),
    'password' => env('DB_PASSWORD', ''),
    'unix_socket' => env('DB_SOCKET', ''),
    'charset' => 'utf8mb4',
    'collation' => 'utf8mb4_unicode_ci',
    'prefix' => '',
    'strict' => true,
    'engine' => null,
],

But there are two errors.Please give me solution for this.

QueryException in Connection.php line 647: SQLSTATE[HY000] [2002] No connection could be made because the target machine actively refused it. (SQL: create table users (id int unsigned not null auto_increment primary key) default character set utf8mb4 collate utf8mb4_unicode_ci)

And

PDOException in Connector.php line 68: SQLSTATE[HY000] [2002] No connection could be made because the target machine actively refused it.

You have to modify env file. There is database configurations that has to modified first than you have to modify database.php file like

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=Your Db Name
DB_USERNAME=Your Db username
DB_PASSWORD=Your Db Password

inews.co.uk, I was quite flattered to be told that my piece had been used in several meetings to convince potential partners - central government and municipal� Í, í (i - acute) is a letter in the Faroese, Hungarian, Icelandic, Czech, Slovak, and Tatar languages, where it often indicates a long /i/ vowel (ee in English word feel). This form also appears in Catalan, Irish, Italian, Occitan, Portuguese, Spanish, Galician, Leonese, Navajo, and Vietnamese language as a variant of the letter “i”.

You should add .env file, see .envexample, and add db configurations, hostname, password, db name.

I (Kendrick Lamar song), noun, plural I's or Is, i's or is. the ninth letter of the English alphabet, a vowel. any spoken sound represented by the letter I or i, as in big, nice, or ski. something� Definition of -i- (Entry 8 of 8) —used as a connective vowel to join word elements especially of Latin origin matrilineal raticide me or I ?: Usage Guide Example Sentences Learn More about i

    'mysql' => [
        'driver' => 'mysql',
        'host' => 'localhost',
        'port' => '3306',
        'database' =>'firstapp',
        'username' => 'root',
        'password' => '',
        'unix_socket' => '',
        'charset' => 'utf8',
        'collation' => 'utf8_unicode_ci',
        'prefix' => '',
        'strict' => true,
        'engine' => null,
],

Please Try it

Letter from Africa: 'How I helped put Gambians on Google Maps', The ninth letter of the basic modern Latin alphabet. I (lower case ı). The letter i without a dot above, in both the upper case and the lower case versions. In the Phoenician alphabet, the letter may have originated in a hieroglyph for an arm that represented a voiced pharyngeal fricative (/ʕ/) in Egyptian, but was reassigned to /j/ (as in English "yes") by Semites, because their word for "arm" began with that sound.

I, Create an account or log in to Instagram - A simple, fun & creative way to capture, edit & share photos, videos & messages with friends & family. Ï, lowercase ï, is a symbol used in various languages written with the Latin alphabet; it can be read as the letter I with diaeresis or I-umlaut.

I, Now I'm complicit in her death. My writing contributed to the dehumanisation of Flack, but it was the the drug of social media rage that made her� Bir hesap oluştur veya Instagram'a giriş yap - Fotoğraf ve videolar çekip düzenlemenin, bu fotoğrafları, videoları ve mesajları arkadaşlarınla ve akrabalarınla paylaşmanın basit, eğlenceli ve yaratıcı yolu.

Instagram, www.will.i.am is the home of everything will.i.am, the multi-faceted entertainer and creative innovator, and a seven-time Grammy Award winner. Log in to i-Ready®, online assessment and instruction that helps teachers provide all students a path to proficiency and growth in reading and mathematics.

Comments
  • upload database schema
  • No connection could be made because the target machine actively refused it. - is MySQL running?
  • i have uploaded schema code.@BilalAhmed. at the top
  • Look for migrations in the Laravel documentation. That's the correct way to create a table in Laravel. By using this, your script attempts to create a table every time you reload the main page. laravel.com/docs/5.4/migrations
  • You mean i should create tables using migrations???
  • sir please specify the location of .env file.
  • .env file is available in root folder of your project.
  • if you are looking for this in IDE than some IDE is not showing hidden files.. so make sure about this.
  • sir i have changed both files .env and .env.example files.
  • are you using latest version of phpmyadmin ?
  • sir i'm not uderstanding .env file.
  • i have changed database.php file in config folder
  • In laravel db configurations set in .env file, .env file should be under root directory, after laravel intalation, there is .envexample file, you can see and create your .env file with your configurations, Please chek documentation of laravel about .env file.
  • In your case it looks like MySQL has not started as you are getting the message that indicates there is no server running and therefore listening for requests. Try start mysql server.