How to access another machine’s database

Asked

Viewed 6,052 times

0

You guys, good night. It is as follows: I am with a PHP project with Mysql to be delivered. However, I am doing it this way: I created 3 virtual machines in Vmware Workstation Pro, the Client is Windows, the one that is only PHP is Ubuntu, and the one that is the database is also Ubuntu. The idea is that it’s a simulation. From the Client machine, I can access the site on the PHP machine through the IP of the machine/filename.php, I can do this without problems. The deal is that I made a form on this PHP site to insert data into the database that is on another machine. Summary of the opera: I’m not getting connection to the database, IE, I can not have remote access to the database, even if I have configured the connection file the right way. I’ve searched a lot of places, both national and foreign, and found nothing. If you can help me, I’d be grateful!!!!!!

2 answers

1

To allow external access to mysql database on a remote server, is to configure it for external access.

  1. Access the file my.cnf and modify the IP parameter bind-address = 127.0.0.1 for 0.0.0.0
  2. Restart mysql
  3. Access mysql from within the server and give access permissions from any IP. mysql> GRANT ALL ON . TO 'root'@'%' IDENTIFIED BY '[password]' WITH GRANT OPTION;
  4. To finish updating privileges mysql> FLUSH PRIVILEGES;
  • It didn’t work :/ already disabled the firewall, already configured the GRANT in mysql, already configured the mysql file but does not connect.. When I load the.php connection page no error appears, it is empty

0

Can you connect to Mysql from your own host? If not, see if it’s running.

sudo service mysql status

If the status is 'active', check that the /etc/mysql/my.cnf file contains the bind-address line 127.0.0.1 . If yes, comment it with # or remove it.

Also check that your firewall is active:

sudo ufw status verbose

If you are, you may need to unlock port 3306 - or another one set as default.

sudo ufw allow from 192.168.* to any port 3306

I hope I helped! Thanks!

  • It didn’t work :/ already disabled the firewall, already configured the GRANT in mysql, already configured the mysql file but does not connect.. When I load the.php connection page no error appears, it is empty

  • Alex, which part didn’t work? Does it work locally? If it does, use heidisql (or another client) to connect remotely. There are also chances that it is network paths configuration problems. Only then use your application or page to try to access. Keep reporting there, maybe we didn’t find the problem.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.