• <tfoot id='EZ0Nh'></tfoot>

      <legend id='EZ0Nh'><style id='EZ0Nh'><dir id='EZ0Nh'><q id='EZ0Nh'></q></dir></style></legend>
        • <bdo id='EZ0Nh'></bdo><ul id='EZ0Nh'></ul>
      1. <small id='EZ0Nh'></small><noframes id='EZ0Nh'>

        <i id='EZ0Nh'><tr id='EZ0Nh'><dt id='EZ0Nh'><q id='EZ0Nh'><span id='EZ0Nh'><b id='EZ0Nh'><form id='EZ0Nh'><ins id='EZ0Nh'></ins><ul id='EZ0Nh'></ul><sub id='EZ0Nh'></sub></form><legend id='EZ0Nh'></legend><bdo id='EZ0Nh'><pre id='EZ0Nh'><center id='EZ0Nh'></center></pre></bdo></b><th id='EZ0Nh'></th></span></q></dt></tr></i><div id='EZ0Nh'><tfoot id='EZ0Nh'></tfoot><dl id='EZ0Nh'><fieldset id='EZ0Nh'></fieldset></dl></div>

        连接到 MySql DB (PHP) 时遇到问题

        时间:2023-10-11

        1. <tfoot id='Do5Lk'></tfoot>
            <tbody id='Do5Lk'></tbody>

          <small id='Do5Lk'></small><noframes id='Do5Lk'>

          <legend id='Do5Lk'><style id='Do5Lk'><dir id='Do5Lk'><q id='Do5Lk'></q></dir></style></legend>
        2. <i id='Do5Lk'><tr id='Do5Lk'><dt id='Do5Lk'><q id='Do5Lk'><span id='Do5Lk'><b id='Do5Lk'><form id='Do5Lk'><ins id='Do5Lk'></ins><ul id='Do5Lk'></ul><sub id='Do5Lk'></sub></form><legend id='Do5Lk'></legend><bdo id='Do5Lk'><pre id='Do5Lk'><center id='Do5Lk'></center></pre></bdo></b><th id='Do5Lk'></th></span></q></dt></tr></i><div id='Do5Lk'><tfoot id='Do5Lk'></tfoot><dl id='Do5Lk'><fieldset id='Do5Lk'></fieldset></dl></div>

            • <bdo id='Do5Lk'></bdo><ul id='Do5Lk'></ul>

                  本文介绍了连接到 MySql DB (PHP) 时遇到问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有以下 PHP 代码可以连接到我的数据库:

                  I have the following PHP code to connect to my db:

                  <?php
                  ob_start();
                  $host="localhost"; // Host name
                  $username="root"; // Mysql username
                  $password=""; // Mysql password
                  $db_name="test"; // Database name
                  $tbl_name="members"; // Table name
                  
                  // Connect to server and select databse.
                  mysql_connect("$host", "$username", "$password")or die("cannot connect");
                  
                  ?>
                  

                  但是,我收到以下错误:

                  However, I get the following error:

                  Warning: mysql_connect() [function.mysql-connect]: [2002] A 
                  connection attempt failed because the connected party did not (trying 
                  to connect via tcp://localhost:3306) in C:Program Files (x86)EasyPHP-
                  5.3.2iwwwchecklogin.php on line 11
                  
                  Warning: mysql_connect() [function.mysql-connect]: A connection 
                  attempt failed because the connected party did not properly respond 
                  after a period of time, or established connection failed because 
                  connected host has failed to respond. in C:Program Files (x86)EasyPHP-
                  5.3.2iwwwchecklogin.php on line 11
                  
                  Fatal error: Maximum execution time of 30 seconds exceeded in 
                  C:Program Files (x86)EasyPHP-5.3.2iwwwchecklogin.php on line 11
                  

                  我可以通过 phpmyadmin 添加数据库/表,但我无法使用 PHP 连接.

                  I am able to add a db/tables via phpmyadmin but I can't connect using PHP.

                  这是我的 phpmyadmin 页面的屏幕截图:可能是什么问题?

                  Here is a screenshot of my phpmyadmin page: What could be the problem?

                  推荐答案

                  检查以下内容:

                  1. MySQL 是否正在运行?
                  2. 是否有任何防火墙会阻止您的计算机接受端口 3306 上的 MySQL 连接?
                  3. MySQL 是在侦听端口 3306,还是更改为非标准的端口?
                  4. 很奇怪,但尝试从 localhost 更改为 127.0.0.1

                  基本上,您收到的错误意味着它无法连接到服务器.它向 localhost:3306 发送请求,并且只等待这么长时间才能得到回复.它没有得到它,这意味着请求被阻止(防火墙)或被忽略(MySQL 没有运行和/或正在侦听不同的端口)

                  Basically, the errors you're getting mean that it cannot connect to the server. It sends request to localhost:3306, and only waits so long for a reply. it's not getting it, which means the request is either blocked (firewall) or ignored (MySQL is not running and/or is listening on a different port)

                  如果 phpMyAdmin 随 MySQL 安装一起提供,那么它可能被配置为使用适当的不同端口

                  If phpMyAdmin came with the MySQL install, then it could be that it was configured to use the appropriately different port

                  这篇关于连接到 MySql DB (PHP) 时遇到问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:PHP 中的 SQL 语句与 phpmyadmin 中的 SQL 语句的行为不同 下一篇:如何使用 php 以 .dat 或 .txt 格式导出文件

                  相关文章

                    <bdo id='NrOoO'></bdo><ul id='NrOoO'></ul>

                  <small id='NrOoO'></small><noframes id='NrOoO'>

                • <legend id='NrOoO'><style id='NrOoO'><dir id='NrOoO'><q id='NrOoO'></q></dir></style></legend>

                    1. <i id='NrOoO'><tr id='NrOoO'><dt id='NrOoO'><q id='NrOoO'><span id='NrOoO'><b id='NrOoO'><form id='NrOoO'><ins id='NrOoO'></ins><ul id='NrOoO'></ul><sub id='NrOoO'></sub></form><legend id='NrOoO'></legend><bdo id='NrOoO'><pre id='NrOoO'><center id='NrOoO'></center></pre></bdo></b><th id='NrOoO'></th></span></q></dt></tr></i><div id='NrOoO'><tfoot id='NrOoO'></tfoot><dl id='NrOoO'><fieldset id='NrOoO'></fieldset></dl></div>
                      <tfoot id='NrOoO'></tfoot>