It is very likely that they are permissions if your application worked correctly locally. You have to activate the remote access to mysql in the mysql configuration.
First you must modify the file my.cnf (the location of this depends on your operating system.We assume linux, but only change the routes, the rest is the same):
sudo nano /etc/mysql/my.cnf
and uncomment the following lines.
#bind-address = 127.0.0.1
#skip-networking
and restart the mysql service
~ /etc/init.d/mysql restart
Then you must give the user remote access privilege ( database
is the name of the base, user
the DB user and password
the password):
GRANT ALL PRIVILEGES
ON database.*
TO 'user'@'%'
IDENTIFIED BY 'password' WITH GRANT OPTION;
or if you want a specific ip ( 1.2.3.4
is the IP)
GRANT ALL PRIVILEGES
ON database.*
TO 'user'@'1.2.3.4'
IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;
and then:
FLUSH PRIVILEGES;
To prove that it can be accessed remotely ( HOST
is the IP or the domain name that we want to access and USER
is the user of the BD):
mysql -h HOST -u USER -p