mysql> GRANT ALL ON yourDatabase.* TO User@'%' IDENTIFIED BY 'my_password';
If you are connecting to a database from an outside computer.
you have to allow your IP address for MySQL remote access.
Please see your IP here:- https://www.whatismyip.com/
note down that IP address.
Login to your cPanel.
Locate the Databases section.
Under the Databases section locate the Remote MySQL option and click on it.
In the next screen, enter the hostname or IP address that you want to grant remote MySQL access to and click the Save button.
If your IP address changes regularly, you can use wildcard by using the % symbol.