SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Sep 2002
    Posts
    180
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    basic mysql connect problems

    I am able to connect to mysql through "local host", but the need has come for me to start connecting via ip addresses, so i can connect to other databases than just the one on my computer.

    However, when i change the connect from 'localhost' to my ip, it does not work....here's the code:

    PHP Code:
    $dbhost '4.4.2.123';
    $dbuser 'root';
    $dbpass 'password';
    function 
    dbConnect($cdb='') {
        global 
    $dbhost$dbuser$dbpass;
        
        
    $dbcnx = @mysql_connect($dbhost$dbuser$dbpass)
            or die(
    'The site database appears to be down.'); 
    Any suggestions?

    Thanks,
    David

  2. #2
    Sell crazy someplace else markl999's Avatar
    Join Date
    Aug 2003
    Location
    Manchester, UK
    Posts
    4,007
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you look at mysql's own 'mysql' table you'll see there's a user table. In there is a Host column and you'll probably see an entry for your user with 'localhost' against it.
    You just need to add a new entry but use the i.p address you want, using the same user/password.

    You could amend the existing entry and change 'localhost' to '%' which would allow connections from anywhere, but it's not recommended. Don't forget to run 'flush privileges' after adding/editing the user (unless you use a GRANT in which case the flush isn't needed)


Bookmarks

Posting Permissions

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