How do I connect to the MySQL database from a different computer?


This question already has an answer here:

  • How to access MySQL from a remote computer (not localhost)? 3 answers

So I haven successfully set up a database in MySQL and can connect to it from the same laptop I set it up on with a small java program. This is fine as it is running on the local host. However, I would like to see if I could now connect to the same database from a different Laptop. The Laptops would be running on the same network.

I can only find information online about connecting with Local host and am starting to feel out of my depth.

What should I do?

Check MYSQL tutorial

  • Get your IP address: first You need to know what the IP address you are connecting from.
  • Granting Access: Granting access to a user from a remote host is fairly simple and can be accomplished from just a few steps. First you will need to login to your MySQL server as the root user.

For Linux (check this site for windows) you can do this by typing the following command:

 # mysql -u root -p
 mysql> GRANT ALL ON fooDatabase.* TO [email protected]'' IDENTIFIED BY 'my_password';

Now you can test your connection remotely. You can access your MySQL server from another server by placing the IP instead of localhost.