我试图从另一台服务器连接到mysql数据库服务器.以下是两台服务器上的配置.
Server 1:
I installed xampp with php and apache services and it has the following ip 172.x1.x1.x1
Server 2:
I installed mysql and it has the following ip 172.x1.x1.x2.
以下是我用来连接数据库的连接脚本
//Database connection constants
define("DATABASE_HOST", "172.x1.x1.x2");
define("DATABASE_USERNAME", "root");
define("DATABASE_PASSWORD", "");
define("DATABASE_NAME", "management");
?>
上面的脚本位于名为app_config.php的文件中,位于服务器1中
以下脚本位于名为connect.php的文件中,它也位于服务器1中
require 'app_config.php';
$connect_error = 'Sorry we\'experiencing connection problems.';
$table_error = 'Table not found';
mysql_connect(DATABASE_HOST, DATABASE_USERNAME, DATABASE_PASSWORD)
or die($connect_error);