I’ve got a short checklist to rule out the simpler causes:
Make sure the machine that hosts the mysql server and the machine connecting to it are on the same vlan
Double check the username and password is correct. If you are using casaos, there are sometimes multiple tabs under the settings menu for containers. Double check that the mysql login info is the same under each tab. For example, Authentic has multiple tabs. One controls the settings for the Authentic frontend, and there is another for the database. Both tabs include mysql login data, and they have to match or it won’t work.
Reboot both machines. Don’t ask me why, but sometimes it just works. Hope this helps.