Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

oshy0294's avatar

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

I am new to Laravel and when I try to execute php artisan migrate, below error comes in cmd. (I am using wamp in win 8.1)

In Connection.php line 664:

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)

In Connector.php line 67:

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

Any help is much appreciated. Thank you

0 likes
7 replies
kvx's avatar

You need to provide database credentials ( database name, user, password ) inside your .env file probably.

DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=dbname
DB_USERNAME=dbuser
DB_PASSWORD=dbpassword
oshy0294's avatar

Sorry couldnt include before

DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=auth DB_USERNAME=root DB_PASSWORD=root

oshy0294's avatar

@rin4ik Thank u very much! Two tables migrations and users were created with below output.

Migration table created successfully. In Connection.php line 664:

SQLSTATE[42000]: Syntax error or access violation: 1071

In Connection.php line 458:

SQLSTATE[42000]: Syntax error or access violation: 1071

rin4ik's avatar

try this in your AppServiceProvider add this line in boot method

public function boot()
{
    Schema::defaultStringLength(191);
}
1 like
oshy0294's avatar

@rin4ik just found this on Laravel News site and seemed to work fine! Thank u very much!

1 like

Please or to participate in this conversation.