2

I have question about how to connect local mysql db of another machine in same LAN. The scenario is we have 2 machines in LAN:

     machine 1 :   
     IP                 : 127.0.0.1    
     local website name :  https://127.0.0.1/demo_project1  
     mysql db name      :  demo1      

     machine 2 :   
     IP : 127.0.0.2  
     local website name :  https://127.0.0.2/demo_project2  
     mysql db name      :  demo2    

Can we do make db connection of https://127.0.0.1/demo_project1 to https://127.0.0.2/demo_project i.e demo2? It means both machine will working on same database.

Note :

  1. we have install on Xampp server on both machines.
  2. we can access https://127.0.0.2/demo_project2 of machine 2 from machine 1.
7
  • Do you mean that they use the same data files, or just that you see the same data on both machines? Commented May 8, 2017 at 6:50
  • You need xampp on both machines if each person works on his localhost apache server, but you need MySQL running on only one of them if you need to work on the same database. You connect to this DB from the remote machine by supplying the LAN IP address, the default MySQL server configuration should allow remote access but that could a a thing to take care of if there will be a problem with remote connection. Commented May 8, 2017 at 6:54
  • @NigelRen , yes i want to see same data on both machines. Commented May 8, 2017 at 6:58
  • Hello @Picard , i have install xampp on both machines so both machine have apache and mysql server also. my question is very simple , i just want to make mysql server db connection of machine 2 from machine1. Commented May 8, 2017 at 7:02
  • Then just check the IP address of the machine where the MySQL is running. I would do windows cmd and then ipconfig - you will see something like: IPv4 Address. . . . .: 192.168.1.108. Then enter this IP address as the IP address of the DB server in the remote machine DB configuration. Commented May 8, 2017 at 7:12

1 Answer 1

0

If the MySQL server is running in a machine which is connected to the same LAN where the second machine is connected, then you can access the MySQL server by specifying it’s IP address.

You can find the IP (IPv4 address), by executing ‘ifconfig’ in the ‘Command Prompt’ (from the Start menu).

You can sync the data between the servers by creating a mysql dump and executing the same dump one the other server. You can automate this process using several MySQL client tools like SQLyog, MySQL Workbench, etc. which provides data sync option between two databases.

Sign up to request clarification or add additional context in comments.

1 Comment

hello I got such a error, Warning: mysqli::__construct(): (HY000/1045): Access denied for user 'testdb'@'localhost' (using password: YES) in C:\xampp\htdocs\connection.php on line 7 Connection failed: Access denied for user 'testdb'@'localhost' (using password: YES)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.