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

linlapkien's avatar

M1 mac Sonoma using Mamp Pro 6.6 connect with Lavarel 10.

I'm a beginner in php - Lavarel, I'm learning through the tutorial. I meet this bug and have find many solutions in laracasts and stackoverflows.

I trying to connect my database. And trying to

php artisan migrate

file .env DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=8889 DB_DATABASE=lavarelsample DB_USERNAME=root DB_PASSWORD=root

Mamp pro 6.6 setting Apache: 8888 Nginx: 7888 mySQL: 8889 Memcached:11211 Redis: 6379

when run "PHP artisan migrate" and then i got this bug

" Illuminate\Database\QueryException

SQLSTATE[HY000] [2002] Connection refused (Connection: mysql, SQL: select table_name as name, (data_length + index_length) as size, table_comment as comment, engine as engine, table_collation as collation from information_schema.tables where table_schema = 'lavarelsample' and table_type in ('BASE TABLE', 'SYSTEM VERSIONED') order by table_name)

at vendor/laravel/framework/src/Illuminate/Database/Connection.php:829 825▕ $this->getName(), $query, $this->prepareBindings($bindings), $e 826▕ ); 827▕ } 828▕ ➜ 829▕ throw new QueryException( 830▕ $this->getName(), $query, $this->prepareBindings($bindings), $e 831▕ ); 832▕ } 833▕ } +36 vendor frames 37 artisan:37"

i found the another solution is change DB_HOST to localhost, i also got bug "SQLSTATE[HY000] [2002] No such file or directory"

my phpadmin User accounts

User name Host name Password Global privileges Grant | kien1 localhost Yes ALL PRIVILEGES Yes | root 127.0.0.1 No ALL PRIVILEGES Yes | root ::1 Yes ALL PRIVILEGES Yes | root localhost Yes ALL PRIVILEGES Yes |

But i have found another solution is using again DB_HOST=localhost, but create a user in phpadmin and grant ALL PRIVILEGES

my .env file: DB_CONNECTION=mysql DB_HOST=localhost DB_PORT=8889 DB_DATABASE=lavarelsample DB_USERNAME=kien1 DB_PASSWORD='Kienlocalhost' <-- this is right password

when run "PHP artisan migrate" and then i also got same bug: "SQLSTATE[HY000] [2002] No such file or director"

Another solutions that i have found is:

i haven't download MySQL ------> solution here: stackoverflow.com/questions/77367823/why-does-php-artisan-migrate-command-resulted-in-sqlstatehy000-2002-conne#:~:text=Update%3A,Troubleshooting%20process%3A

I do download 8.0.37 -arm64 for my mac, after i start MySQL Server, i try my DB_User as root & kien1

i got this bug:

" Illuminate\Database\QueryException

SQLSTATE[HY000] [1045] Access denied for user 'kien1'@'localhost' (using password: YES) (Connection: mysql, SQL: select table_name as name, (data_length + index_length) as size, table_comment as comment, engine as engine, table_collation as collation from information_schema.tables where table_schema = 'lavarelsample' and table_type in ('BASE TABLE', 'SYSTEM VERSIONED') order by table_name)"

can anyone have me find this solution, I've been stuck on this error for 4 days

0 likes
3 replies
Snapey's avatar

check your credentials for accuracy

did you really name your database DB_DATABASE=lavarelsample ?

1 like
linlapkien's avatar

@Snapey yes sure, i have checked many times the username & password, and even create the new one, and set it ALL PRIVILEGES permission.

The database name is accuracy, and I have tried to create a new one, but it's not the credentials problem. I don't know if it conflict to my own MySQL server.

linlapkien's avatar

Update: i used MySQL Workbench instead, Mamp may not work for me.

Please or to participate in this conversation.