问题描述
我正在使用Ngrok将开发网站本地链接到Internet,但不适用于MysqL服务器。 这是config.inc.PHP中的代码:
$cfg['Servers'][$i]['host'] = 'localhost'; // MysqL hostname or IP address
$cfg['Servers'][$i]['port'] = '8889'; // MysqL port - leave blank for default port
$cfg['Servers'][$i]['socket'] = ''; // Path to the socket - leave blank for default socket
$cfg['Servers'][$i]['connect_type'] = 'tcp'; // How to connect to MysqL server ('tcp' or 'socket')
$cfg['Servers'][$i]['extension'] = 'MysqL'; // The PHP MysqL extension to use ('MysqL' or 'MysqLi')
这是我的Ngrok配置的代码:
authtoken: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
tunnels:
server:
proto: http
addr: 8888
Db1:
proto: tcp
addr: 8889
我可以访问Apache服务器,但不能访问MysqL数据库(它可以在本地运行,因此显然是转发问题,但我无法解决)。
编辑:
这是我的Ngrok正在运行:
Forwarding tcp://0.tcp.ngrok.io:16097 -> localhost:8889
Forwarding http://b342784fc9ec.ngrok.io -> http://localhost:8888
Forwarding https://b342784fc9ec.ngrok.io -> http://localhost:8888
我的pdo用于本地配置:
<?PHP
$user = 'root';
$pass = 'root';
$dbname = 'dbtest';
$host = 'localhost';
$port = '8889';
$pdo = new PDO('MysqL:host=' . $host . ';dbname=' . $dbname . ';port' . $port . ';charset=utf8',$user,$pass);
?>
我的pdo用于在线配置:
<?PHP
$user = 'root';
$pass = 'root';
$dbname = 'dbtest';
$host = 'tcp://0.tcp.ngrok.io';
$port = '16097';
$pdo = new PDO('MysqL:host=' . $host . ';dbname=' . $dbname . ';port' . $port . ';charset=utf8',$pass);
?>
因此,基本上,本地计算机正在运行,而不是在线计算机,但是也许我做错了事,因为网络不是专家。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)