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
Solved

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

Posted on 2010-11-26
11
754 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 77

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 77

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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 

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 77

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 77

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
A procedure for exporting installed hotfix details of remote computers using powershell
This tutorial will give a short introduction and overview of Backup Exec 2012 and how to navigate and perform basic functions. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as conne…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

839 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