Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Mon Apr 16, 2012 9:55 pm 
Offline
Junior Member

Joined: Sun Apr 15, 2012 7:31 pm
Posts: 25
Rookie question.

I want to be able to connect to my MySQL via php, so that my website can access the database. For this to happen, do I need to have remote access turned on?

Also, in your php connection...

$host = "localhost";
$user= "MRblahblah";
$pass = "blahblah";
$dbname = "blahDB";

is the host 'localhost' for a Linode? Or is it something to do with the user I created for my Linode (the user that replaces root after I stop root access), or something to do with the host name and FQDN (say my hostname is 'MrQuestion' and the FQDN is 'theBridge').

Thanks guys - I'm almost set up, but misunderstanding some of the fundamentals here, and can't find in the guide where to answer these questions.


Top
   
 Post subject:
PostPosted: Mon Apr 16, 2012 10:03 pm 
Offline
Senior Member

Joined: Wed Jun 08, 2011 11:25 pm
Posts: 51
If your website is running on the same server as mysql, then no, you don't need remote access turned on. Leave $host as localhost so it'll know to connect to mysql on this server and not somewhere else.


Top
   
 Post subject:
PostPosted: Tue Apr 17, 2012 12:52 am 
Offline
Senior Member

Joined: Fri Jan 20, 2012 11:19 am
Posts: 100
See this page for information on how to connect to MySQL your database from PHP.

_________________
If all else fails, reboot...
PHP Tutorials and MySQL Tutorials


Top
   
PostPosted: Tue Apr 17, 2012 4:19 am 
Offline
Senior Member
User avatar

Joined: Tue Mar 17, 2009 5:11 am
Posts: 129
Location: UK
billygoatkaraoke wrote:

Also, in your php connection...

$host = "localhost";
$user= "MRblahblah";
$pass = "blahblah";
$dbname = "blahDB";

is the host 'localhost' for a Linode? Or is it something to do with the user I created for my Linode


The username, password are your MySQL user account parameters, it's not the same thing as your linux username.


Top
   
 Post subject: securing mysql
PostPosted: Tue Apr 17, 2012 4:31 pm 
Offline
Junior Member

Joined: Fri Jul 08, 2011 7:46 pm
Posts: 44
Website: http://ericsonwilkinson.me
Location: United States
Not a stupid question, yes you access it through localhost and don't need to turn on remote access to the mysql server daemon.

Run this command: mysql_secure_installation
Google what all the questions are if you get confused, but this will help secure your installation. Set a really good password for the root. Don't use your mysql root account for php, create another account with only access to the databases it needs for php interaction.

reference for adding mysql users: http://dev.mysql.com/doc/refman/5.1/en/ ... users.html


Last edited by Ericson578 on Wed Apr 18, 2012 1:49 pm, edited 1 time in total.

Top
   
 Post subject:
PostPosted: Wed Apr 18, 2012 1:18 am 
Offline
Junior Member

Joined: Sun Apr 15, 2012 7:31 pm
Posts: 25
Hey guys

Thanks for all your help.

It's been a great learning experience, but I've opted to go with a managed host - too many variables for me to bugger up doing it myself.

I appreciated your time.

Shaun


Top
   
 Post subject:
PostPosted: Wed Apr 18, 2012 7:00 am 
Offline
Senior Member
User avatar

Joined: Sat Feb 25, 2012 4:44 pm
Posts: 71
Website: http://inhomeitsupport.com
Don't give it!

Learning Linux there is a big learning curve,but when you master it and understand it,it will be worth it.


Top
   
 Post subject:
PostPosted: Wed Apr 18, 2012 8:14 am 
Offline
Junior Member

Joined: Sun Apr 15, 2012 7:31 pm
Posts: 25
hahaha - I understand where your coming from. I have to put that learning curve time into working on my site though (which comes with it's own learning curve). The priority is the site for now.

But learning what I have in the last few days setting up the Linode as much as I did has made it wayyyy easier to understand what's going on under the hood. Plus, I didn't know what SSH was before this, so learning some of that was worth it alone - now I understand a bit more about how DB admins connect etc.

Thanks mate - your help was fantastic.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group