1

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.

halfer
  • 19,824
  • 17
  • 99
  • 186
S R R
  • 73
  • 8
  • The command about `setsebool` should be run on the shell - could you try that? – Nico Haase Nov 27 '18 at 09:04
  • thanks for your reply. i run this command on zampp shell and get error : setsebool is not recognized as an internal or external command, operable program or batch file. – S R R Nov 27 '18 at 09:18
  • try making sure that you execute the command from the directory setsebool.exe is in, or supply the absolute path to the executable. – JoSSte Nov 27 '18 at 11:29
  • could you get the providers to check if they get any oddities in the logs? https://stackoverflow.com/questions/10474922/error-2006-hy000-mysql-server-has-gone-away indicates something to do with packet size. I doubt that is the solution for you, but maybe the XAMPP server is generating something wrong / in anoder codepage or something like that... as I understand the error, your client actually gets contact to the serverm, and loses the connection. – JoSSte Nov 27 '18 at 11:39
  • @JoSSte , i don't know where is the setsebool directory and I set max_allow_packet=128M but still have problem. can you test to connect my database remotely from your computer please? – S R R Nov 27 '18 at 12:19
  • `jss@idefix:~$ php db.php Connected successfully` – JoSSte Nov 27 '18 at 12:37
  • `locate setsebol` – JoSSte Nov 27 '18 at 12:38
  • @JoSSte , do you have any special config on your XAMPP? why can you connect and i don't ? – S R R Nov 27 '18 at 13:00
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/184324/discussion-between-s-r-r-and-josste). – S R R Nov 27 '18 at 13:02

0 Answers0