Thread: MySQL Help!

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    2
    Rep Power
    0

    MySQL Help!


    Hello Everybody,
    I have previously developed MySQL systems for basic PHP sites, but feel I am ready to take to the next level. I have always had a MySQL Database provided by a company (in this case 4uhosting.co.uk) which I was able to easily control via cpanel, then phpMyAdmin.

    I am working on a quite large system and didn't want to rely on any other services,so i've decided to buy a static computer and have MySQL Community Server running. I have managed to complete this successfully. My issue is I don't know how I can access the database for my system. So I can access it locally simply by 'localhost' and the user root. I have input these details to my php connection page and a connection isn't being established and was wondering how about I get my community server software to publish the database so it's on the web, or whether I am simply putting in the wrong information. Any help would be greatly appreciated! Thanks, Aaron
  2. #2
  3. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,056
    Rep Power
    9398
    First things first: Is MySQL running on the same machine as PHP? Or are they separate?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    2
    Rep Power
    0
    Originally Posted by requinix
    First things first: Is MySQL running on the same machine as PHP? Or are they separate?
    Hi thanks for getting back to me. The PHP is published from the same computer from which the MySQL Community Server is running. Thanks
  6. #4
  7. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,056
    Rep Power
    9398
    Create a user with the privileges your PHP script needs. That's probably SELECT, INSERT, and UPDATE, and possibly DELETE too. It should be as limited as you can get away with. The hostname for the user would just be "localhost", so you might issue
    Code:
    CREATE USER 'phpuser'@'localhost' IDENTIFIED BY 'password';
    GRANT SELECT, INSERT, UPDATE ON *.* TO 'phpuser'@'localhost';
    Then use that account in your PHP code. Make it connect to "localhost". If that doesn't work then mysqld isn't set up to use whatsit sockets - those are the best things you can use but only available when MySQL and whatever software tries to use it (like PHP) are on the same machine.

IMN logo majestic logo threadwatch logo seochat tools logo