Php connect database with port
Asked 7 years, 10 months ago Show Viewed 12k times I've got my own DB.php and it was working before I changed the MySQL Port to something else other than 3306 which is default. It fails to connect now; I've configured the DB.php after port change like below :
Can anyone tell me how I can make it work with the port number 669 again? Thanks. asked Nov 20, 2014 at 9:12 1 The Fix:You are passing wrong parameter to
Reference:http://php.net/manual/en/function.mysql-connect.php P.S.Note: MySQL library is deprecated please use MySQLi or PDO instead answered Nov 20, 2014 at 9:14
Syed QaribSyed Qarib 4,7265 gold badges25 silver badges38 bronze badges 1 Here is the PDO way.
The most important part is the first parameter of the constructor answered Oct 4, 2020 at 15:15
Serge KishikoSerge Kishiko 4061 gold badge6 silver badges12 bronze badges (PHP 4, PHP 5) mysql_connect — Open a connection to a MySQL Server Descriptionmysql_connect( Parametersserver 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. username The username. Default value is defined by mysql.default_user. In SQL safe mode, this parameter is ignored and the name of the user that owns the server process is used. password The password. Default value is defined by mysql.default_password. In SQL safe mode, this parameter is ignored and empty password is used. new_link If a second call is made to mysql_connect() with the same arguments, no
new link will be established, but instead, the link identifier of the already opened link will be returned. The client_flags
The Return Values Returns a MySQL link identifier on success or ExamplesExample #1 mysql_connect() example
Example #2
mysql_connect() example using
Example #3 mysql_connect() example using ":/path/to/socket" syntax
$link = mysql_connect(':/tmp/mysql', 'mysql_user', 'mysql_password'); Notes
See Also
nicodenboer at yahoo dot com ¶ 10 years ago
Steve ¶ 14 years ago
VTool ¶ 5 years ago
sky dot sama dot remove dot dots at Gmail dot com ¶ 15 years ago
pepik at gmail dot cz ¶ 9 years ago
Peter Robinett ¶ 14 years ago
cory dot mawhorter gmail.com ¶ 13 years ago
jslakva at gmail dot com ¶ 15 years ago
martin ¶ 15 years ago
Ignacio Casinelli Esviza ¶ 14 years ago
= @mysql_connect($server,$user,$pass); amn -at- frognet.net ¶ 19 years ago
avinc@live,hk ¶ 11 years ago
tpl99 at yandex dot ru ¶ 12 years ago
Harouk ¶ 11 years ago
martinnitram at excite dot com ¶ 18 years ago
Graham_Rule at ed dot ac dot uk ¶ 15 years ago
Graham_Rule at ed dot ac dot uk ¶ 19 years ago
aeolianmeson at blitzeclipse dot com ¶ 14 years ago
abelcheung at gmail dot com ¶ 12 years ago
angelo [at] mandato 15 years ago
GetMyConnection() arithmetric at gmail dot com ¶ 14 years ago
bimal at sanjaal dot com ¶ 11 years ago
brinca at substancia dot com ¶ 15 years ago
trev at dedicate dot co dot uk ¶ 10 years ago
chaoscontrol_hq at yahoo dot com ¶ 18 years ago
rui dot batista at netcabo dot pt ¶ 16 years ago
yangqingrong at wudimei dot com ¶ 9 years ago
pascalxusNOSPAM at yahoo dot com ¶ 14 years ago
Anonymous ¶ 17 years ago
Contact at LinuxIntro dot com ¶ 13 years ago
sholland at napervillegi dot com ¶ 12 years ago
david dot schueler at wapkamera dot de ¶ 13 years ago
dan at novapulsar dot com ¶ 14 years ago
?>
php at lanar dot com dot au ¶ 10 years ago
bmagilavy at avalon-internet dot com ¶ 14 years ago
How can you connect to database in PHP?In PHP, we can connect to the database using XAMPP web server by using the following path.. Start XAMPP server by starting Apache and MySQL.. Write PHP script for connecting to XAMPP.. Run it in the local browser.. Database is successfully created which is based on the PHP code.. Can we connect to any database from PHP?PHP Data Objects (PDO) is an extension that serves as an interface for connecting to databases. Unlike MySQLi, it can perform any database functions and is not limited to MySQL. It allows flexibility among databases and is more general than MySQL. PDO supports both server and client-side prepared statements.
How do I connect to MySQL port 3306?How to Allow Remote Connections to MySQL. Step 1: Edit MySQL Config File.. Step 2: Set up Firewall to Allow Remote MySQL Connection. Option 1: UFW (Uncomplicated Firewall) Option 2: FirewallD. Option 3: Open Port 3306 with iptables.. Step 3: Connect to Remote MySQL Server.. What is use of mysql_connect in PHP?mysql_connect() establishes a connection to a MySQL server. The following defaults are assumed for missing optional parameters: server = 'localhost:3306', username = name of the user that owns the server process and password = empty password. The server parameter can also include a port number.
|