Solved

Windows Server 2008: phpMyAdmin cannot connect to mysql but mysql cmdline connect works

Posted on 2010-11-26
11
750 Views
Last Modified: 2012-06-22
Hi there!

I am trying to install phpmyadmin on a Windows Server 2008 box but I cannot connect. PhpMyadmin displays the following error message: #2002 - The server is not responding (or the local MySQL server's socket is not correctly configured)

When I try to connect to mysql with the cmd line tool it works perfectly. I am using PhpMyAdmin 3.3.8 and a MySQL 5.1 server and PHP 5.3.3.

There is nothing in the windows logs and nothing in the PHP logs. I also checked that session.save_path is writable by everybody.

When it tries to connect it doesn't return immediately with the error message but it takes about 20 seconds. So I reckon something is blocking the request. I also tried it with all ports open.

It also doesn't seem to be a phpmyadmin problem since I tried to install drupal and it also fails when trying to connect to the database.

I am running out of ideas what can git wrong here. Hopefully someone can help me out.

Regards,
Dirk.
0
Comment
Question by:dirkil2
  • 7
  • 4
11 Comments
 
LVL 76

Expert Comment

by:arnold
ID: 34218564
Are you using the localhost 127.0.0.1 as the destination or the private IP 192.168./172.16-31./10.?
root login is configured by default with localhost login rights only.

Use the IP 127.0.0.1 when configuring phpmyadmin and trying to connect .
0
 

Author Comment

by:dirkil2
ID: 34218634
That doesn't make any difference. The request comes always from localhost since the IIS / PHP mysql extension is generating the connect request to mysql.
0
 
LVL 76

Expert Comment

by:arnold
ID: 34218740
Check the configuration of your mysql to make sure it is listening on a socket 3306. (rerun the mysql configuration utility if needed.)
The mysql command line tool works differently,
see if the following works as well with the command line tool
mysql -h 127.0.0.1 -u root -p
the same way that it does when using
mysql -u root

0
 

Author Comment

by:dirkil2
ID: 34218836
@arnold

Thanks for your ideas. I tried them both and in both cases I can login.
0
 

Author Comment

by:dirkil2
ID: 34218870
I have another interesting information! I wrote some php code that connects to the database and that worked! So there must be something different in the way phpMyAdmin does it.
<?php
  $conn = mysql_connect('127.0.0.1', 'root', '<mypwd>') or die ('Error connecting to mysql');
  mysql_select_db('mysql');
  $result = mysql_query('SELECT * FROM user') or die("Query failed");
  echo "Connected successfully.";
  mysql_close($conn);
?>

Open in new window

0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:dirkil2
ID: 34218896
Here is my config.inc.php.

It doesn't make a difference whether I use extension mysql or mysqli.
<?php

/* vim: set expandtab sw=4 ts=4 sts=4: */

/**

 * phpMyAdmin sample configuration, you can use it as base for

 * manual configuration. For easier setup you can use setup/

 *

 * All directives are explained in Documentation.html and on phpMyAdmin

 * wiki <http://wiki.phpmyadmin.net>.

 *

 * @version $Id$

 * @package phpMyAdmin

 */



/*

 * This is needed for cookie based authentication to encrypt password in

 * cookie

 */

$cfg['blowfish_secret'] = 'MkmEmJT4XYKdt3YUg)%+Hjsqto)8P7c]IaNYqeGBn8H'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */



/*

 * Servers configuration

 */

$i = 0;



/*

 * First server

 */



$i++;

/* Authentication type */

$cfg['Servers'][$i]['auth_type'] = 'cookie';

/* Server parameters */

$cfg['Servers'][$i]['host'] = 'localhost';

$cfg['Servers'][$i]['connect_type'] = 'tcp';

$cfg['Servers'][$i]['compress'] = false;

/* Select mysqli if your server has it */

$cfg['Servers'][$i]['extension'] = 'mysqli';

$cfg['Servers'][$i]['AllowNoPassword'] = false;





/* rajk - for blobstreaming */

$cfg['Servers'][$i]['bs_garbage_threshold'] = 50;

$cfg['Servers'][$i]['bs_repository_threshold'] = '32M';

$cfg['Servers'][$i]['bs_temp_blob_timeout'] = 600;

$cfg['Servers'][$i]['bs_temp_log_threshold'] = '32M';



/* User for advanced features */

// $cfg['Servers'][$i]['controluser'] = 'pma';

// $cfg['Servers'][$i]['controlpass'] = 'pmapass';

/* Advanced phpMyAdmin features */

// $cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';

// $cfg['Servers'][$i]['bookmarktable'] = 'pma_bookmark';

// $cfg['Servers'][$i]['relation'] = 'pma_relation';

// $cfg['Servers'][$i]['table_info'] = 'pma_table_info';

// $cfg['Servers'][$i]['table_coords'] = 'pma_table_coords';

// $cfg['Servers'][$i]['pdf_pages'] = 'pma_pdf_pages';

// $cfg['Servers'][$i]['column_info'] = 'pma_column_info';

// $cfg['Servers'][$i]['history'] = 'pma_history';

// $cfg['Servers'][$i]['tracking'] = 'pma_tracking';

// $cfg['Servers'][$i]['designer_coords'] = 'pma_designer_coords';

/* Contrib / Swekey authentication */

// $cfg['Servers'][$i]['auth_swekey_config'] = '/etc/swekey-pma.conf';



/*

 * End of servers configuration

 */



/*

 * Directories for saving/loading files from server

 */

$cfg['UploadDir'] = '';

$cfg['SaveDir'] = '';



?>

Open in new window

0
 
LVL 76

Expert Comment

by:arnold
ID: 34218999
Within the phpmyadmin directory, there is a config file.
You may have defined the host as the name or as anything other than localhost.

Which version of phpmyadmin and which version of mysql do you have?
0
 

Author Comment

by:dirkil2
ID: 34219049
@arnold

I mentioned the version number already in my first post.

Right now I am debugging where the connect happens in file libraries\dbi\mysql.dbi.lib.php.

I modified the code so that I get more information. This line is executed:
$link = @mysql_connect($server, $user, $password, false, $client_flags);

But I changed it to:
$link = mysql_connect($server, $user, $password, false, $client_flags) or die(mysql_error());

And I got this message:
"A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond."

By the way, $server='localhost' and $client_flags=128.

I am still not understanding why my simple example works but the phpmyAdmin fails.
0
 

Accepted Solution

by:
dirkil2 earned 0 total points
ID: 34219102
I found the solution !!!!

When I entered 127.0.0.1 instead of localhost it worked straight away. As you can see in my little sample I used 127.0.0.1; this was by accident.

It seems that on my box the name resolution is blocked. Any idea where I can allow that?
0
 
LVL 76

Assisted Solution

by:arnold
arnold earned 500 total points
ID: 34219151
Sorry, must have scanned right past the phpmyadmin,mysql versions.

Usually the hosts file is in: c:\windows\system32\drivers\etc\hosts

In your case, the location might be different
http://support.microsoft.com/kb/972034
i.e. c:\windows\syswow64\drivers\etc\hosts

Within the command window on this system, run nslookup localhost and see what it returns.
Then try ping localhost and see what IP the response is coming from.
0
 

Author Closing Comment

by:dirkil2
ID: 34281065
I award you the points since you helped me find the solution.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to create an extensible mechanism for linked drop downs.
This tutorial will walk an individual through the steps necessary to configure their installation of BackupExec 2012 to use network shared disk space. Verify that the path to the shared storage is valid and that data can be written to that location:…
The viewer will learn how to count occurrences of each item in an array.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now