Solved

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

Posted on 2010-11-26
11
756 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 78

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 78

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
Get Database Help Now w/ Support & Database Audit

Keeping your database environment tuned, optimized and high-performance is key to achieving business goals. If your database goes down, so does your business. Percona experts have a long history of helping enterprises ensure their databases are running smoothly.

 

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 78

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 78

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

Comparison of Amazon Drive, Google Drive, OneDrive

What is Best for Backup: Amazon Drive, Google Drive or MS OneDrive? In this free whitepaper we look at their performance, pricing, and platform availability to help you decide which cloud drive is right for your situation. Download and read the results of our testing for free!

Question has a verified solution.

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

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
This tutorial will give a an overview on how to deploy remote agents in Backup Exec 2012 to new servers. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as connecting to a remote Back…
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…

752 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