Solved

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

Posted on 2010-11-26
11
755 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
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MySQL limit and not so limited 13 34
AD Account lockout 11 63
Using Case or If statement in Select statement, result is a string. Need a number. 4 46
BgInfo help 5 59
The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
A safe way to clean winsxs folder from your windows server 2008 R2 editions
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

735 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