In few words, you have to configure MySQL to allow remote connections, create a user for connecting and setup your firewall to allow it. You don’t have to do this if you are only connecting from a local application like WordPress.
You need root permissions to perform the following commands.
Configuring MySQL Edit the MySQL configuration file.
nano /etc/my.cnf Allow connections from all your network interfaces by commenting out the following line: