mysql link mysql_connect([string host[:port|:/path/to/socket]], 
 [string username], [string password]) 
host Host to connect to, with an optional port or socket component
username Username to log in with
password Password to log in with

Connects to a MySQL server.


MySQL link on success; FALSE on failure


mysql_connect() is used to connect to a local or remote MySQL server. Normally it’s used as follows:

$mysql_link = mysql_connect ('some_host', 'some_user', 'some_password'); 

You can also let PHP supply optional arguments for all parameters.

The host argument should contain a domain name or an IP address, optionally followed by a port number. If no port number is specified, the default MySQL port of

Get PHP Functions Essential Reference now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.