Jump to content

Remote MYSQL access


lie2815

Recommended Posts

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.

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...