skip to Main Content

I am using a MAMP server to host my laravel project. I am trying to push my database migrations table which I have created to the MAMP phpmyadmin database hosted on the localhost 8888 server.

However everytime I use the command , php artisan migrate I get this error:

SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) (SQL: select * from information_schema.tables where table_schema = laravel and table_name = migrations and table_type = 'BASE TABLE')

I have tried everything to change stuff in the .env file and the database.php file but nothing seems to be changing.

This is what my .env file looks like(only relevant parts):

APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:H5A9PbNQk0we6UJnNzSZ68Y22B88SK6wCEq2wachQfE=
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack
LOG_LEVEL=debug

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME="root"
DB_PASSWORD="temp"
UNIX_SOCKET=/Applications/MAMP/tmp/mysql/mysql.sock
DB_SOCKET=/Applications/MAMP/tmp/mysql/mysql.sock

This is what my database.php file looks like:

 'mysql' => [
            'driver' => 'mysql',
            'url' => env('DATABASE_URL'),
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', 3306),
            'database' => env('DB_DATABASE', 'laravel'),
            'username' => env('DB_USERNAME', 'root'),
            'password' => env('DB_PASSWORD', 'temp'),
            'unix_socket' => env( 'DB_SOCKET','/Applications/MAMP/tmp/mysql/mysql.sock'),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'prefix_indexes' => true,
            'strict' => true,
            'engine' => null,
            'options' => extension_loaded('pdo_mysql') ? array_filter([
                PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
            ]) : [],
        ],

Here is a picture of what the user accounts look like, what I have available:
enter image description here

2

Answers


  1. Make sure u use the right username and password in phpmyadmin
    And replace them in .env file and config/database.php file

    Login or Signup to reply.
  2. Try running php artisan config:clear and also php artisan cache:clear.

    If that won’t help try and login to the database using command line or bash if the credentials work.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search