如何连接到WAMP服务器上的MySQL? [英] How can I connect to MySQL on a WAMP server?
本文介绍了如何连接到WAMP服务器上的MySQL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这对您来说可能很容易,但是我已经为此苦苦挣扎一个小时了...:(
This might be ridiculously easy for you but I've been struggling with this for an hour... :(
<?php
$connect = mysql_connect("localhost:8080", "root", "mypassword");
echo($connect);?>
这是我要运行的代码-您可以看到我使用8080作为我的端口号,当然,我也有HTML代码.
This is the code that I'm trying to run - you can see that I'm using 8080 as my port number and, of course, I have HTML codes as well.
但是,每当我尝试打开PHP文件时,它都会给我以下错误消息:
However, it gives me the following error messages whenever I try to open the PHP file:
Warning: mysql_connect() [function.mysql-connect]: MySQL server has gone away in C:\wamp\www\php_sandbox\index.php on line 2
Warning: mysql_connect() [function.mysql-connect]: Error while reading greeting packet. PID=4932 in C:\wamp\www\php_sandbox\index.php on line 2
Warning: mysql_connect() [function.mysql-connect]: MySQL server has gone away in C:\wamp\www\php_sandbox\index.php on line 2
我不知道...这是怎么回事?是因为端口号吗?
I don't know... what's wrong with this? Is it because of the port number?
推荐答案
将localhost:8080更改为localhost:3306.
Change localhost:8080 to localhost:3306.
这篇关于如何连接到WAMP服务器上的MySQL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文