Problems with MySql connection

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Problems with MySql connection

Postby steen.mf » 03. August 2006 00:00

Hi. I have a problem with MySql connection.
Have just installed XAMPP on Win XP. Apache service is up and running fine, but when I try to connect to db i get this error-message:
Warning: mysql_connect() [function.mysql-connect]: Lost connection to MySQL server during query in C:\Xampp\xampp\htdocs\xampp\cds.php on line 64
Could not connect to database!
Is MySQL running or did you change the password?

When I check for status in the xampp dir I get that MySql is "deactivated" - but in the task manager I can see that mysqld.exe is running. And when I check for security in the xampp dir I get this:
The MySQL admin user root has no longer no password

Have tried to reset password without luck. Have checked in WinMySQLAdmin and in config.inc in phpMyAdmin - and the user is "root" and password is "" in both places.
Seems that i´m running out of options and i really hope that someone out there can help me out on this one.
steen.mf
 
Posts: 3
Joined: 02. August 2006 23:37

Postby Izzy » 03. August 2006 00:53

steen.mf wrote:Quote:
Warning: mysql_connect() [function.mysql-connect]: Lost connection to MySQL server during query in C:\Xampp\xampp\htdocs\xampp\cds.php on line 64
Could not connect to database!
Is MySQL running or did you change the password?

The error message is telling you what is wrong. You changed the password from none to a mySQLpassword. Now cd.php has no idea what that password is to access the database cdcol

Go to C:\Xampp\xampp\htdocs\xampp\cds.php and find line 65:
Code: Select all
   if(!mysql_connect("localhost","root",""))

Add your mySQL password that you added in the Security page in between "" so it looks like this:
Code: Select all
   if(!mysql_connect("localhost","root","mySQLpassword"))


Save and close. Now try the CD Collection menu item again.

This applies to any php script that has to access a database on your server.
all these are needed for a script to access a database on your server:
the name of the database
the user of the database
the database user's password
the host the database is located on (usually, but not limited to, localhost).

For example this part of cd.php has all those needed items:
Code: Select all
   if(!mysql_connect("localhost","root","mysqlpassword"))
   {
      echo "<h2>".$TEXT['cds-error']."</h2>";
      die();
   }
   mysql_select_db("cdcol");
Host=localhost
Database User=root
Database User Password=mysqlpassword (yours goes here)
Database Name=cdcol

HTH :)
Last edited by Izzy on 03. August 2006 01:24, edited 1 time in total.
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Postby Wiedmann » 03. August 2006 01:22

steen.mf wrote:Lost connection to MySQL server during query

http://dev.mysql.com/doc/refman/5.0/en/gone-away.html

This is a new installation without any changes in MySQL?

When I check for status in the xampp dir I get that MySql is "deactivated" - but in the task manager I can see that mysqld.exe is running.

You can try this in the shell (cmd.exe) to see if MySQL is working:
Code: Select all
cd C:\Xampp\xampp\mysql\bin
mysqladmin --user=root ping

or
Code: Select all
mysqladmin --user=root --password=yourpass ping

if you have a password for the user root.
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby steen.mf » 03. August 2006 15:47

Hello - and many thanks for prompt replies.
The problem is that this is a new installation of Xampp and I haven´t changed the MySql password, it is still "" in both config.ini (phpMyAdmin) and in WinMySQLAdmin. When running the codes:
cd C:\Xampp\xampp\mysql\bin
mysqladmin --user=root ping

or:
mysqladmin --user=root --password=yourpass ping

I get the message: error: "lost connection to the MySql server during query".

Another strange thing is that my XAMPP control panel seems to be corrupt: although both apache and mysql are running it doesn´t show in the panel, and I can´t start them through the panel - have to start them "manually" with the .bat files in the xampp dir. Weird?

Any ideas what might be wrong? - or what to try next?
steen.mf
 
Posts: 3
Joined: 02. August 2006 23:37

Postby Wiedmann » 03. August 2006 15:56

You have a firewall or something else on your box?

--> A clean installation must working out of the box (a mysqladmin ping is a really simple command...). And MySQL can start (task manager)... Maybe there is something wrong with your Windows or network configuration.
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Eureka!

Postby steen.mf » 03. August 2006 20:45

That did it! Turned off the Norton Firewall and then it worked, could connect to MySql. Thanx a million! - But how to do with the firewall? Can´t have it wide open everytime I work with the MySql. What adjustments to make in the firewall to let the db connect but have the firewall´s security still going?
And what about this:
Another strange thing is that my XAMPP control panel seems to be corrupt: although both apache and mysql are running it doesn´t show in the panel, and I can´t start them through the panel - have to start them "manually" with the .bat files in the xampp dir. Weird?
Reinstall the Xampp Control panel? Or is there anything else to do?

And again - very greatful for your help!
steen.mf
 
Posts: 3
Joined: 02. August 2006 23:37

Postby Wiedmann » 03. August 2006 21:08

MySQL is using port 3306. Make an exception for this port and/or the MySQL program. If this does not work, ask Symantec.
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 44 guests