Search code examples
javamysqljdbcphpmyadminmamp

Upload MySQL database and access on Java application from a remote system


I recently built a desktop application using Java for the frontend and MySQL for the backend database. Now I want everyone else to be able to use this application too.

So my question is how can I upload my MySQL database online and so that the application can access it remotely? What changes should I make in my I used MAMP to create and setup this database. The first thing I did was....

connection = DriverManager.getConnection("jdbc:mysql://" + host + "/" + database, username, password);

Then I added a new MySQL user using

CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';

GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' WITH GRANT OPTION;

CREATE USER 'username'@'%' IDENTIFIED BY 'password';

GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' WITH GRANT OPTION;

FLUSH PRIVILEGES;

and I also created a my.cnf file and added

bind-address = 192.168.1.45

Now on the remote system I get the

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

Solution

  • If you want your database to be accessed from outside you have to host it to a server, you have the option to do it locally (you have to setup a local server) or using a database cloud service like Azure or Amazon Web Services (AWS).

    Edit: I also found this for you:
    www.GearHost.com provides free hosting for both MS SQL and MySQL. The limit on free database MSSQL is 10 MB.

    Source: https://www.quora.com/Is-there-any-free-SQL-Server-hosting-available

    https://aws.amazon.com/free/ that's a service offered by Amazon which lets you host your database for 12 Months for free, after that you'll get charged (or not) depending on the Tier you've chosen.