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 oracle集群安装出bug
    • ¥15 关于#python#的问题:自动化测试
    • ¥15 教务系统账号被盗号如何追溯设备
    • ¥20 delta降尺度方法,未来数据怎么降尺度
    • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
    • ¥15 再不同版本的系统上,TCP传输速度不一致
    • ¥15 高德地图点聚合中Marker的位置无法实时更新
    • ¥15 DIFY API Endpoint 问题。
    • ¥20 sub地址DHCP问题
    • ¥15 delta降尺度计算的一些细节,有偿