是否可以将mysql连接到xampp登录,这会导致我的sql服务器丢失?

lawou6xi  于 2021-06-17  发布在  Mysql
关注(0)|答案(1)|浏览(307)

在unity中,我将用户名和密码传递到login.php,然后出现了“mysqlserver away”。我设置如下。
php.ini文件

post_max_size = 750M
upload_max_filezie = 750M
max_execution_time = 1200
max_input_time = 5000
memory_limit = 1000 M
max_allowed_packet = 200M

phpmyadmin/config.inc.php
+添加

$cfg ['ExecTimeLimit'] = 6000;

+添加my.ini

innodb_look_wait_timeout=600

如果我在网址中输入localhost:8080/escape\u room/login.php,结果屏幕会显示很长时间。我想就这件事征求意见。
+登录.php

<?php
$servername = "localhost:8080";
$username="root";
$password="";
$dbName="escape_room";
$user_username = $_POST['Input_user'];
$user_password = $_POST['Input_pass'];
$conn = new mysqli($servername, $username, $password, $dbName);
if(!$conn){
    die("Cound not Connect: " . mysqli_connect_error());
}

$sql = "SELECT pass FROM escape_room WHERE user = '".$user_username."' ";
$result = mysqli_query($conn, $sql);

//Get the result and confirm login 
$numrows = mysqli_num_rows($result);
if($numrows == 0)
{
    die("ID does not exist \n");
}
else{
    while($row = mysqli_fetch_assoc($result)){
        if($row['pass'] == $user_password){ 
            echo "login success";
            echo $row['pass'];  
        }else{
            echo "password incorrect";
            echo "password is =". $row['pass'];
        }

    }
}

?>

错误如下。

mysqli :: _construct(): MySQLserver has gone away
mysqli :: _construct(): Error While reading greeting packet PID=7572
mysqli :: _construct(): (HY000/2006) : MySQL server has gone away
e4yzc0pl

e4yzc0pl1#

听起来像 8080 是apache配置为运行的端口,而不是mysql。您应该从连接字符串中删除:

$servername = "localhost";

如果在自定义端口上运行它,则应将其作为连接调用的第五个参数传入。
127.0.0.1 对你来说可能比 localhost .

相关问题