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
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.
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".
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.
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.
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?
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.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now