Solved

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

Posted on 2010-11-26
11
764 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 4
11 Comments
 
LVL 79

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 79

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
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 

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
 

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 79

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 79

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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
This tutorial will walk an individual through configuring a drive on a Windows Server 2008 to perform shadow copies in order to quickly recover deleted files and folders. Click on Start and then select Computer to view the available drives on the se…
This tutorial will walk an individual through setting the global and backup job media overwrite and protection periods in Backup Exec 2012. Log onto the Backup Exec Central Administration Server. Examine the services. If all or most of them are stop…

617 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