Error when Migrating, can't connect to database?

Posted 9 months ago by Gabotronix

Hello I am new to laravel and tried to do my first migration today. I created a costadog database with phpmyadmin, then I changed both config/database and .env file default credentials to this:

'mysql' => [
            'driver' => 'mysql',
            'host' => env('DB_HOST', ''),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'costadog'),
            'username' => env('DB_USERNAME', 'root'),
            'password' => env('DB_PASSWORD', 'root'),
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8',                              //antes era: utf8mb4
            'collation' => 'utf8mb4_unicode_ci',              //antes era: utf8mb4_unicode_ci
            'prefix' => '',
            'strict' => true,
            'engine' => null,



after executing php artisan migrate I got the following errors:

   Illuminate\Database\QueryException  : SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) (SQL: select * from information_schema.tables where table_schema = costadog and table_name = migrations)

  at C:\xampp\htdocs\Costadog\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|         }

  Exception trace:

  1   PDOException::("SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)")

  2   PDO::__construct("mysql:host=;port=3306;dbname=costadog", "root", "root", [])

  Please use the argument -v to see more details.

Please sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up


Reply to

Use Markdown with GitHub-flavored code blocks.