我有一个项目的离线版本和相同的项目在线更新了大型数据库记录,我想从本地主机和我的试验中访问服务器上托管的数据库:
否1:
<?php
// mysql_connect('localhost', 'root', '');
// mysql_select_db('eghtml5_XXXX');
$dbserver="http://96.127.132.74:xxxx";
$username="xxxxx";
$password="xxxxx";
// $username="root";
// $password="";
$dbname="database_name";
$connection=mysql_connect("$dbserver","$username","$password")or die("could not connect to the server");
mysql_select_db($dbname, $connection) or die("Error here");
mysql_query("SET NAMES utf8;");
mysql_query("SET CHARACTER_SET utf8;");
?>
另一个试验将此配置附加到本地主机的php.ini
$i++;
$cfg['Servers'][$i]['host'] = '96.127.132.74';
$cfg['Servers'][$i]['port'] = 'XXXX';
$cfg['Servers'][$i]['socket'] = '';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['compress'] = FALSE;
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'xxxx';
$cfg['Servers'][$i]['password'] = 'ْْxxxx';
两种方式都没有与我合作!
答案 0 :(得分:0)
检查您尝试登录的用户是否允许从不是&#34; localhost&#34;的位置进行连接。或在线服务器的IP。
您必须检查端口3306(MySQL STD端口)是否打开以从外部连接(可能是安全问题)