首页 > 代码库 > PHP远程连接mysql
PHP远程连接mysql
http://blog.chinaunix.net/uid-23215128-id-2951624.html
# mysql -uroot
mysql> use mysql;Database changedmysql> SELECT `Host`,`User` FROM `user`;+-----------+--------+| Host | User |+-----------+--------+| 127.0.0.1 | houtai || 127.0.0.1 | root || ::1 | root || localhost | houtai || localhost | root |+-----------+--------+5 rows in set (0.00 sec)mysql> UPDATE `user` SET `Host` = ‘%‘ WHERE `User` = ‘root‘ LIMIT 1;Query OK, 1 row affected (0.00 sec)Rows matched: 1 Changed: 1 Warnings: 0mysql> SELECT `Host`,`User` FROM `user`;+-----------+--------+| Host | User |+-----------+--------+| % | root || 127.0.0.1 | houtai || 127.0.0.1 | root || ::1 | root || localhost | houtai |+-----------+--------+5 rows in set (0.00 sec)mysql> flush privileges;
远程写个PHP脚本测试:
<?php$con = mysqli_connect("IP","root","密码");if (!$con) { die(‘Could not connect: ‘ . mysql_error()); } else echo"connect ok!"?>
服务器要关闭防火墙: iptables -F (service iptables stop)
显示: connect ok!
PHP远程连接mysql
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。