Results 1 to 7 of 7
  1. #1
    Join Date
    May 2004
    Location
    Scotland
    Posts
    3

    Change MySQL host name

    I plan to develop a MySQL/PHP website offline. I have both MySQL and PHP installed offline. The MySQL server has hostname 'localhost' but the online MySQL server (which will be used for online website) has host name 'rumpus'.

    Can anyone give me the information required to change my offline hostname to 'rumpus' so that I can simulate the online website, offline.

    Cheers,
    Bailz.

  2. #2
    Join Date
    Apr 2004
    Location
    France
    Posts
    119
    My advice, if you're with Windows, edit the file C:\WINNT\system32\drivers\etc\hosts and add the following line :

    127.0.0.1 rumpus

    Now, I think you can connect to your local database with rumpus and/or localhost.

    But it's not a good idea to do that Instead, put the database host name in a variable read from a config file...

    And btw best place for this post would be the programming forum...

    David.

  3. #3
    Join Date
    Sep 2002
    Location
    Top Secret
    Posts
    11,686
    What's giving you problems? The sql hostname or apache? Most likely, it's apache, as sql doesn't (usually) care about your host unless you're trying to connect remotely.

    If it's apache, you can edit the configs in httpd.conf to point to that hostname. There's quite a few that need to be edited in there, so make sure you do a thorough job of looking for "hostname" and replacing it.
    WHMCS Guru - WHMCS addons, management, support and more.
    WHMCS Notifications Extended - Add slack, hipchat, SMS, pushover to WHMCS !!
    Always looking for Linux, WHMCS, Support Desk work. PM for details

  4. #4
    Join Date
    May 2004
    Location
    Scotland
    Posts
    3
    Neither are giving me problems it's just that I want to simulate my virtual web server offline. It's hostname is rumpus but offline I can only seem to get localhost.

    I'm using Abyss not Apache.

    I'll have a look at what dgauss said.

    Thanks a lot guys,
    Bailz.

  5. #5
    Join Date
    May 2004
    Location
    Scotland
    Posts
    3
    Ok, changing the drivers/etc/hosts didn't work. Could you give me some details of the config file please. I'm not a natural programmer (other than php) so I might have some difficulty without some help.

    Thanks,
    Bailz.

  6. #6
    Join Date
    Jul 2002
    Location
    UK
    Posts
    2,026
    can't you just edit your code from localhost to rumpus when you're working locally?

    this seems like a whole load of trouble for no reason
    Gone.

  7. #7
    Join Date
    Apr 2004
    Location
    France
    Posts
    119
    You could create a new file called config.php and insert a line in this file like :

    $DB_host = 'rumpus''

    In your current php script, include your config file with this line :

    include('config.php');

    Then, you can change the $DB_host variable on your local machine to "localhost", and keep "rumpus" only in the config file on your server.

    Hope that helps, but else a better place could be php tutorial, php forums or books...

    David.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •