mysql link to website other then localhost

Posted on 2004-11-27
Last Modified: 2013-12-13
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?
Question by:marisanel
    LVL 5

    Accepted Solution

    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.
    LVL 8

    Expert Comment

    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 :)
    LVL 5

    Expert Comment

    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 :)
    LVL 8

    Expert Comment

    heh mms_master,
    When we use ipconfig, I think what show up is the Proxy server address, right?
    that's what happen here.
    LVL 5

    Expert Comment

    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...
    LVL 1

    Expert Comment


    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.
    LVL 40

    Expert Comment

    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.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Suggested Solutions

    Title # Comments Views Activity
    SASS Files in Wordpress 1 25
    What does this mean? 6 24
    Is COM supported from Apache 1 19
    How do companies protect source code? 4 32
    As this topic comes over and over again in different forms, I've finally decided to write a short (yea, right...) article / tutorial about pagination with PHP with MySQL database. There are dozens of these kind of tutorials, I know - I wanted to mak…
    Part of the Global Positioning System A geocode ( is the major subset of a GPS coordinate (, the other parts being the altitude and t…
    The viewer will learn how to dynamically set the form action using jQuery.
    The viewer will learn how to count occurrences of each item in an array.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now