Ghostff
Ghostff

Reputation: 1458

How to connect to mysql localhost database with a different computer

i have a laptop and a desktop, i saved all the database information on the desktop, is there anyway i can connect to the desktop sql database while working with the laptop? this is what i have tried on the laptop

define("DB_SERVER", "192.0.0.45");     //desktop ip (made up)
define("DB_USER", "root");            //desktop database usr
define("DB_PASS", "");               //desktop database password
define("DB_NAME", "scroll");         //desktop database name

i use this 192.0.0.45 to access the files in the desktop localhost eg(192.0.0.45/page) and it works

Upvotes: 0

Views: 3317

Answers (3)

Zakarie Abdallah
Zakarie Abdallah

Reputation: 472

make sure the desktop and the laptop are in same network the go to your browser and enter 192.0.0.45/phpmyadmin if the port is 80 else 192.0.0.45:'port_no'/phpmyadmin without qoutes

Upvotes: 2

In your httpd.conf find Listen 127.0.0.1:80 and replace it with Listen 80 or Listen *:80. Now find Allow from 127.0.0.1 and change it to Allow from all. Now you can access the localhost on your desktop machine via your IPv4 ip. You can find it by typing in ipconfig for windows ifconfig on Linux. You must type in the ip address of your desktop machine. You can find many related stuff on stackexchange community like serverfault.com or superuser.com.

Upvotes: 2

marcopeg
marcopeg

Reputation: 1228

your local installation of MySQL should be locked down to be accessed from localhost by default for security reasons.

In order to access your db from another machine you need to unlock this setting.
With tools like MAMP Pro you have an GUI that helps you in configuring this setting:

enter image description here

To practically configure your local MySQL please refer to this StackOverflow thread:
MySQL can connect locally but not remotely

IMPORTANT: this option will create a security issue on your machine, I suggest to open up MySQL only during development sessions and then close it up as quick as you can. Especially if you plan to to this on an Internet accessible machine!

Upvotes: 1

Related Questions