mysql link to website other then localhost

I have an website runing on the other webhosting, that use an mysql database.
I want to use an mysql database located on my computer.
Is that possible? And how?
Who is Participating?
mms_masterConnect With a Mentor Commented:
Yes it is possible...

All you have to do is change:

$Host = "localhost"; //Or you may use $Host = "";


$Host = "your_ip";


$User = "root";
$Password = "password";
$Host = "198.542.158.125"; //Replace 198.542.158.125 with the ip address of your computer.

$Link = mysql_conect($Host, $User, $Password) or die(mysql_error());

Hope this helps :)

Or if you are running the database from your pc, I take it you are going to leave it on all the time. So you could always host the website from your pc and keep $Host as localhost.
Hi marisanel,
based on mms solution
$host ='your_ip';
okay, in case you do not know how to find your ip address, you can use this:
1- go to start
2- click run
3- type 'cmd' without the two quotes
4- type ping your_computer_name  <= your_computer_name is a name of your own computer where the mysql database is

Cheers :)
Or an even easier way incase you dont know your pc name is:

If you have 95/98/ME:

Not sure if ME uses this way, if not do same as for 2000/XP

Go To Start
click run
type 'winipcfg' without the quotes
a window with a few numbers will appear, look for the one with 'IP Address:' next to it (without the quotes)

If you have 2000/XP:

Go to Start
click run
type '' without the quotes
type 'ipconfig' without the quotes
look for the number with 'IP Address:' next to it (without the quotes

Thanks :)
Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

heh mms_master,
When we use ipconfig, I think what show up is the Proxy server address, right?
that's what happen here.
Don't know I've never used a proxy lol...
But if marisanel dosn't use I proxy I think my way is easier, otherwise your way is...

if you want a mysql database on your localhost, check out

there are windows binaries and lots of easy, detailed instructions on how to set it up.
you can then access the database with phpmyadmin for (what i think) is the easiest way to use mysql. If you dont have a web server on the same pc as you want the database on, look at the commands in mysql documentation to add a hostmask of your webserver IP address so you can access your local database from your webserver.
Richard QuadlingSenior Software DeveloperCommented:
You have a web site capable of running PHP and MySQL.

You want to use the database on YOUR pc and not the one provided to you by the hoster.

If this is correct then the following points should be taken into consideration.

1 - Your pc will need to be online with a static IP address for the entire time.
2 - Your pc and the database will need adequate protection to allow only the required connections.
3 - Your ISP may have certain terms and conditions which restrict the running of servers.
4 - Your bandwidth is probably shared with other local users. This may impact upon your website as it tries to get requests through to your pc.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.