Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I connect to MySQL on a WAMP server?

Tags:

php

mysql

wamp

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);?>

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.

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?

like image 442
Phrixus Avatar asked Mar 16 '10 23:03

Phrixus


People also ask

Does WAMP include MySQL?

Both stacks have PHP, Apache, and a variety of other applications required for an application and website to run. WAMP Server includes MySQL for database purposes; however, XAMPP currently includes MariaDB instead of MySQL.

Why MySQL in WAMP is not working?

Please check the port that MySQL is using on your system. Then, change the port number of the WAMP server's MySQL service to that number by entering it in my. ini. If you're running Windows, make sure to restart service and it immediately turns green.


1 Answers

Change localhost:8080 to localhost:3306.

like image 112
JonnyLitt Avatar answered Oct 05 '22 02:10

JonnyLitt