PHP连接MySQL服务器老是出错 20
这是代码:<?phpmysql_connect("127.0.0.1:8080","root","")ordie("数据库链接错误".mysql_error());mys...
这是代码:
<?php
mysql_connect("127.0.0.1:8080","root","") or die("数据库链接错误".mysql_error());
mysql_select_db("ruanjian",'') or die("数据库访问错误".mysql_error());
mysql_query("set names utf8_general_ci");
?>
浏览器显示的错误:
Warning: mysql_connect() [function.mysql-connect]: MySQL server has gone
away in D:\WWW\conn.php on line 2
Warning:
mysql_connect() [function.mysql-connect]:
Error while reading greeting packet. PID=8380 in D:\WWW\conn.php on line
2
Warning: mysql_connect() [function.mysql-connect]: MySQL server has gone
away in D:\WWW\conn.php on line 2
Fatal error:
Maximum execution time of 30 seconds exceeded in D:\WWW\conn.php on line
2 展开
<?php
mysql_connect("127.0.0.1:8080","root","") or die("数据库链接错误".mysql_error());
mysql_select_db("ruanjian",'') or die("数据库访问错误".mysql_error());
mysql_query("set names utf8_general_ci");
?>
浏览器显示的错误:
Warning: mysql_connect() [function.mysql-connect]: MySQL server has gone
away in D:\WWW\conn.php on line 2
Warning:
mysql_connect() [function.mysql-connect]:
Error while reading greeting packet. PID=8380 in D:\WWW\conn.php on line
2
Warning: mysql_connect() [function.mysql-connect]: MySQL server has gone
away in D:\WWW\conn.php on line 2
Fatal error:
Maximum execution time of 30 seconds exceeded in D:\WWW\conn.php on line
2 展开
2个回答
展开全部
3306端口吧,不是8080
<?php
$host="localhost";
$db_user="root"; //用户名
$db_pass="1"; //密码
$db_name="lianxi"; //数据库名
$timezone="Asia/Shanghai";
$link=mysql_connect($host,$db_user,$db_pass);
mysql_select_db($db_name,$link);
mysql_query("SET names UTF8");
header("Content-Type: text/html; charset=utf-8");
date_default_timezone_set($timezone); //北京时间
?>
<?php
$host="localhost";
$db_user="root"; //用户名
$db_pass="1"; //密码
$db_name="lianxi"; //数据库名
$timezone="Asia/Shanghai";
$link=mysql_connect($host,$db_user,$db_pass);
mysql_select_db($db_name,$link);
mysql_query("SET names UTF8");
header("Content-Type: text/html; charset=utf-8");
date_default_timezone_set($timezone); //北京时间
?>
展开全部
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询