Home > Backend Development > PHP Tutorial > mysql联接命令行可以php竟然不可以

mysql联接命令行可以php竟然不可以

WBOY
Release: 2016-06-13 12:46:22
Original
1331 people have browsed it

mysql连接命令行可以php竟然不可以
我在web主机上用mysql -h 192.168.7.14 -uroot -proot -D sheep 可以连接到远程数据库,查看到里面的数据。
但是同一台服务器上用php去连竟然失败了

<br />
<?php<br />
define('DB_HOST', '192.168.7.14:3306');<br />
define('DB_USER', 'root');<br />
define('DB_PASSWORD', 'root');<br />
define('DB_NAME', 'sheep');<br />
<br />
$conn=mysql_connect(DB_HOST,DB_USER,DB_PASSWORD) or die("wrong while connect DB!");<br />
mysql_select_db(DB_NAME,$conn) or die("wrong while select DB!");<br />
mysql_query("set names utf8");<br />
echo "test";<br />
mysql_close($conn);<br />
?><br />
Copy after login

直接就输出“wrong while connect DB!”,端口去掉也不行,不用常量直接写在mysql_connect参数里面也不行。防火墙我都关了,web目录下都是root所有者和组。
还有啥可能的?

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template