MatiaDB-MySQL"文档说明第二项说明“The default Database manager port is 3306. Connections that do not specify the port number will always be on the default port.”,意为默认连接数据库的端口号为3306当你使用以下代_wamp">
赞
踩
The default Database manager port is 3306. Connections that do not specify the port number will always be on the default port.
If the database manager (MySQL or MariaDB) you want to use is not the default one, it is therefore imperative to specify the port number in connection requests since it will not be using the default port 3306. We repeat, without specifying the port, it will be the default port that will be used, so 3306.
Normally, connection scripts do not mention the port to use. For example:
$mysqli = new mysqli('127.0.0.1', 'user', 'password', 'database');
or, in procedural :
$mysqli = mysqli_connect('127.0.0.0.1', 'user', 'password', 'database');
So, to connect with a manager that doesn't use port 3306, you have to specify the port number on the connection request:
$mysqli = new mysqli('127.0.0.1', 'user', 'password', 'database', '3307');
or, procedurally:
$mysqli = mysqli_connect('127.0.0.0.1', 'user', 'password', 'database', '3307');
To check the connections on the MySQL or MariaDB database manager, use the script:
wamp(64)\www\testmysql.php
by putting 'http://localhost/testmysql.php' in the browser address bar having first modified the script according to your parameters.
$mysqli = new mysqli('127.0.0.1', 'user', 'password', 'database');
或者
$mysqli = mysqli_connect('127.0.0.0.1', 'user', 'password', 'database');
$mysqli = new mysqli('127.0.0.1', 'user', 'password', 'database', '3307');
或者
$mysqli = mysqli_connect('127.0.0.0.1', 'user', 'password', 'database', '3307');
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。