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">
当前位置:   article > 正文

wamp64 mysql更改端口号后网页中无法访问数据库_wamp64改了端口号为什么进不去网站

wamp64改了端口号为什么进不去网站


前言

上篇文章更改完mysql的端口号后网页无法连接数据库,按提示查看文档 “帮助->MatiaDB-MySQL",即点击下图中的“帮助->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

在这里插入图片描述

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.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

当你使用以下代码,即省略了端口号的方式连接数据库时,程序会以3306访问数据库

$mysqli = new mysqli('127.0.0.1', 'user', 'password', 'database');
  • 1

或者

$mysqli = mysqli_connect('127.0.0.0.1', 'user', 'password', 'database');
  • 1

解决方法

将网页文件中连接数据库的语句加上目前mysql或MariaDB使用的端口号即可

$mysqli = new mysqli('127.0.0.1', 'user', 'password', 'database', '3307');
  • 1

或者

$mysqli = mysqli_connect('127.0.0.0.1', 'user', 'password', 'database', '3307');
  • 1
声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号