January 12th, 2013, 12:33 PM
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
January 13th, 2013, 12:57 AM
First things first: Is MySQL running on the same machine as PHP? Or are they separate?
January 13th, 2013, 04:17 AM
Hi thanks for getting back to me. The PHP is published from the same computer from which the MySQL Community Server is running. Thanks
Originally Posted by requinix
January 13th, 2013, 04:56 AM
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
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.
CREATE USER 'phpuser'@'localhost' IDENTIFIED BY 'password';
GRANT SELECT, INSERT, UPDATE ON *.* TO 'phpuser'@'localhost';