Avatar of star6868
star6868
 asked on

How to accelerate PHP-mysql persistent connection?

My server IP is '11.0.0.17' (local), with APACHE, PHP, MYSQL

I use following php script for mysql connection:

<?php
//$link = mysql_connect('localhost', 'test', 'password');
$link = mysql_connect('11.0.0.17', 'test', 'password');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);

?>

I use mysql_connect, with real IP, prepare for Remote connection, but it seem slow
- If I use command: $link = mysql_connect('localhost', 'test', 'password'); ---> connect very fast, complete immediately!
- But when I use command: $link = mysql_connect('11.0.0.17', 'test', 'password'); ---> connection completed in about 5 seconds. --> very SLOW. (Press F5 to refresh is also slow!)

I also use mysql_pconnect to replace, but it's the same!
How to make connection faster with real IP ?
PHP

Avatar of undefined
Last Comment
star6868

8/22/2022 - Mon
star6868

ASKER
I want to explain more: when this script run with "'localhost" parameter, it run very fast, but when it run with Real IP, it run slow (take 5 second to complete script)
I need solution for Real IP (remote connection)!

Thanks very much!
ASKER CERTIFIED SOLUTION
star6868

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy