dor65412 2018-11-27 09:00
浏览 1165

如何配置XAMPP以远程连接MySQL

I have a problem to connect my online MySQL database from my local system.

I installed XAMPP on my Windows 7 and created a PHP file with this code:

<?php
    $db_path = mysqli_connect('printcity24.com', 'printci1_admin', 'xr10s20191', 'printci1_db', '3306');
    if(!$db_path) {
        echo mysqli_connect_error();
    }else{
        echo "Connected successfully";
    }
?>

Then i created a database on my website : www.printcity24.com

My web host admin configured my host and opened firewall.

When i use XAMPP command line to connect to my database every thing is ok, i can connect to my database remotely with this code :

# mysql -u printci1_admin -p -h printcity24.com

but when i use php code to connect to my database i get this error :

 Warning: mysqli_connect(): MySQL server has gone away in D:\Xampp Server\htdocs\st\index.php on line 2

Warning: mysqli_connect(): (HY000/2006): MySQL server has gone away in D:\Xampp Server\htdocs\st\index.php on line 2
MySQL server has gone away

I upload my php code on to other websites and test for connection and everything is "ok" but on my local xampp can't connect.

In this link said i have to use this command :

setsebool -P httpd_can_network_connect=1 

but I don't know where to put this code and how to configure my xampp.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 关于#python#的问题:求帮写python代码
    • ¥20 MATLAB画图图形出现上下震荡的线条
    • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
    • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
    • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
    • ¥15 perl MISA分析p3_in脚本出错
    • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
    • ¥15 ubuntu虚拟机打包apk错误
    • ¥199 rust编程架构设计的方案 有偿
    • ¥15 回答4f系统的像差计算