2
votes

Hello I just recently started using Laravel and I can't seem to create a database table using migration. It gives me this error when I input php artisan migrate enter image description here

Can't seem to find the answer to the problem, here is my .env:

APP_ENV=local
APP_KEY=base64:xsHVPf6IVsYHsTs71fbOxRgs86bW3B+M2FhhPh4bNro=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=MyDB
DB_USERNAME=AmielDB
DB_PASSWORD=root

BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

PUSHER_APP_ID=
PUSHER_KEY=
PUSHER_SECRET=

and here's my database.php:

'connections' => [

        'sqlite' => [
            'driver' => 'sqlite',
            'database' => env('DB_DATABASE', database_path('database.sqlite')),
            'prefix' => '',
        ],

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

        'pgsql' => [
            'driver' => 'pgsql',
            'host' => env('DB_HOST', 'localhost'),
            'port' => env('DB_PORT', '5432'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'charset' => 'utf8',
            'prefix' => '',
            'schema' => 'public',
            'sslmode' => 'prefer',
        ],

    ],
3

3 Answers

0
votes

If you configure your database after run the laravel server then you have to restart your server i mean mysql and apache then try again. And are you sure your passowrd is root? Please ensure your Database, UserName & Password.

0
votes

Are you sure you didn't interchanged username and password???

If u set .env after served(php artisan serve), you need to exit and serve again.

0
votes

Just a side note;

Sometimes you can forget you web server is down then you get the terrifying "Access denied!".

Spent sometime other time having configured system wide access to PHP path but later realized I hadn't brought up the web server, Apache in my case.

Hope it helps someone!