lie2815 Posted July 8, 2008 Posted July 8, 2008 I already allowed the appropiate host to have access to my server, but what do I have to use as the MySQL host when connecting via PHP Quote
meriadoc Posted July 8, 2008 Posted July 8, 2008 Based on your statement/question it sounds like you have set up a user on the MySQL server and that user has permission to make a connection from your web server. Once the user is in place, three things are needed to make the connection to your MySQL server. A hostname, username and password. When using php it will look something like this... $dbhost = 'NameorIPofMySQLhost'; $dbuser = 'papasmurf'; $dbpass = 'lalalalalalaa'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); If the web server and MySQL server are one in the same you can use 'localhost' as your $dbhost. Quote
Ashoat Posted July 8, 2008 Posted July 8, 2008 Close, but I believe you also have to have a port number in there. The "$dbhost" value needs to be "heliohost.org:3306". Quote
meriadoc Posted July 8, 2008 Posted July 8, 2008 Good idea to mention the optional inclusion of a port value. From my understanding it is only necessary if the default port (3306) is not used and the mysql.default_host directive is undefined. Here is an excerpt from the PHP: mysql_connect - Manual. server The MySQL server. It can also include a port number. e.g. "hostname:port" or a path to a local socket e.g. ":/path/to/socket" for the localhost. If the PHP directive mysql.default_host is undefined (default), then the default value is 'localhost:3306'. In SQL safe mode, this parameter is ignored and value 'localhost:3306' is always used. Quote
Ashoat Posted July 9, 2008 Posted July 9, 2008 Hmm, I was under the impression that cPanel used a port other than the default. My bad. Quote
lie2815 Posted July 9, 2008 Author Posted July 9, 2008 The point I was trying to make is that I am trying to access MySQL from another server than my webserver... But if I understood you correctly, I just have to use heliohost.org:3306 Is that right? Quote
Bass5098 Posted July 9, 2008 Posted July 9, 2008 Yes, that is what you should have to use. Currently when i am connecting using remote mysql i keep getting an error but it should still work. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.