mysql> GRANT ALL ON yourDatabase.* TO User@'%' IDENTIFIED BY 'my_password';
If you are connecting to database from 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 Databases section locate Remote MySQL option and 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.