wamp mysql无法连接到本地主机

Posted

技术标签:

【中文标题】wamp mysql无法连接到本地主机【英文标题】:wamp mysql cannot connect to localhost 【发布时间】:2011-09-08 17:36:32 【问题描述】:

你好 我试图按照在线 tut 在 mysql 中设置密码,现在这导致了我无法恢复的错误。

1) phpMyAdmin-2.11.10 这给出了下面有消息的登录框:无法加载 mcrypt。我已在 wamp 中启用并将 libmcrypt.dll 放在 windows 和 windows\system32 文件夹中。但仍然会收到消息。如果我将 root 放入登录框而没有通过,这会导致第二个错误。

2) mysql错误

1130 - 主机 'localhost' 不允许连接到这个 MySQL 服务器

我尝试了各种修复,但似乎没有任何效果。我将不胜感激。谢谢

phpMyAdmin-2.11.10 mysql4.1.22 php4.4.7

phpmyadmin config.inc.php

<?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 scripts/setup.php
 *
 * All directives are explained in Documentation.html and on phpMyAdmin
 * wiki <http://wiki.phpmyadmin.net>.
 *
 * @version $Id: config.sample.inc.php 12304 2009-03-24 12:56:58Z nijel $
 */

/*
 * This is needed for cookie based authentication to encrypt password in
 * cookie
 */
$cfg['blowfish_secret'] = ''; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

/*
 * Servers configuration
 */
$i = 0;

/*
 * First server
 */
$i++;
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'config';
/* Server parameters */
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
/* Select mysqli if your server has it */
$cfg['Servers'][$i]['extension'] = 'mysql';
/* 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]['designer_coords'] = 'pma_designer_coords';

/*
 * End of servers configuration
 */

/*
 * Directories for saving/loading files from server
 */
$cfg['UploadDir'] = '';
$cfg['SaveDir'] = '';

?>

【问题讨论】:

听起来您在 MySQL 中登录的用户名(通过 phpmyadmin)的“host”字段设置为“localhost”或“%”(任何主机)以外的其他值。 【参考方案1】:

据我所知,Wamp 已经配置了 phpMyAdmin。你用过什么教程?

乐:

这是 root 用户还是其他帐户?如果我是你,我会备份我的数据(文件和 sql),重新安装 wamp(最新版本不是你教程中的版本)并执行以下操作:

开始->运行,输入cmd 使用 cd 命令导航 mysql.exe 的安装位置

使用以下命令:

mysql>
mysql>update mysql.user SET password=password("newpassword") hit enter
mysql>where user="root"; hit enter
Query OK


mysql>Flush Privileges; hit enter
Query OK
mysql>quit hit enter
mysql>bye

然后去phpMyAdmin config.inc 编辑

$cfg['Servers'][$i]['password'] = 'newpassword';

重新启动 WAMP 服务器,现在应该可以了。

【讨论】:

您是否仔细检查过在 php 中启用了 mcrypt 扩展?如果是,请尝试重新启动整个 Wamp 设置。 为了在没有密码的情况下不会出错,您必须在 config.inc.php 文件中添加 $cfg['Servers'][$i]['AllowNoPassword'] = true; @Bdesign 我有而且还是一样。在出现几条错误消息后,我设法进入了 phpmyadmin,但它现在告诉我我无法创建数据库。在 mysql 表中的用户中,我所有的权限都说是。呸呸呸 好的。现在我可以登录,但每次我选择一个表时,我都必须再次登录,并且我收到消息 localhost is not allowed to connect。另外,我仍然没有创建数据库的权限。谢谢 更新。我刚刚登录时收到此消息:1800 秒内没有活动;请重新登录。我只有在单击 mysql 数据库中的用户表时才得到它。谢谢

以上是关于wamp mysql无法连接到本地主机的主要内容,如果未能解决你的问题,请参考以下文章

MySQL Workbench 连接到 AWS,收到错误“无法连接到本地主机”

VB.Net 应用程序无法连接到本地 MySQL,但我可以从命令连接

如何从 AWS SAM 本地 docker 实例连接到主机 MySQL?

Visual Studio 2010无法连接到MySql服务器

Android设备无法连接到本地主机中的mysql [关闭]

jmx 无法连接到本地主机