if you're using docker and connect to the database server that resides on the host you'll need to use %.

If you've created a mysql user as YOUR-USER@localhost you won't be able to connect.

the solution is to update the mysql.user table but not directly.

RENAME USER 'YOUR-USER'@'localhost' TO 'YOUR-USER'@'%';

Sometimes you've host to use : 172.17.0.1 instead of host.docker.internal if you can't connect

Related

https://serverfault.com/questions/483339/changing-host-permissions-for-mysql-users

Referral Note: When you purchase through a referral link (if any) on this page, we may earn a commission.
If you're feeling thankful, you can buy me a coffee or a beer