mysql - 无法通过phpMyAdmin访问数据库

标签 mysql authentication phpmyadmin xampp

基本上,我的 config.inc.php 文件有问题。但我会描述事件的顺序,以防我搞砸了我不知道的其他事情。

我已经在 phpMyAdmin 中构建了一个数据库,我已经在本地主机上使用了几个月。它与 XAMPP 一起安装。根据 XAMPP/xamppfiles/phpMyAdmin/README 文件,它是 phpMyAdmin 版本 3.5.7

有一段时间,我离开了 ['controluser'] = 'pma' 和 ['controluserpass'] = 'pmapass'。几周前,我更改了这些值,但这显然造成了一个问题,因为 phpMyAdmin 开始向我展示

"Connection for controluser as defined in your configuration failed"

时刻提醒。尽管如此,我仍然能够做我需要做的一切;所以我一直在使用我的数据库。

昨天,我不得不终止一个持续了 8 个多小时的查询。之后,phpMyAdmin 加载其他数据库和表的速度似乎有点慢。所以我打开了 XAMPP 并按下了 MySQL 的停止按钮。显然,这个按钮不再为我停止 MySQL。该图标只是旋转和旋转,好像在思考。因此,从今天开始,我一直在直接从终端而不是通过 XAMPP 控制界面停止和启动 MySQL。

因为我看到了针对 controluser 的警告,所以我决定重写 config.inc.php 文件以解决那里存在的任何问题。不幸的是,我只会让事情变得更糟。现在我根本无法访问我的数据库。

我今天花了 5 个小时研究如何设置我的 config.inc.php 文件,但我仍然无法访问我的数据库。过去,我使用“配置”选项设置它,而无需输入密码。理想情况下,我更愿意拥有密码安全性。但在这个阶段,我很乐意重新获得对我的数据库的访问权限。

现在,localhost/phpmyadmin 进入登录页面,默认为“用户名”输入“root”。但我似乎无法登录。根据我对 config.inc.php 所做的调整,有时“用户名”默认为乱码;有时会出现错误消息而不是登录。无论我输入什么密码,phpMyAdmin 都不会接受它:

2002 Cannot log in to the MySQL server

其他时候,我得到这个错误:

2002 - Can't connect to local MySQL server through socket '/Applications/XAMPP/xamppfiles/var/mysql/mysql.sock' (2) The server is not responding (or the local server's socket is not correctly configured).

我试过在两者之间来回切换

$cfg['Servers'][$i]['auth_type'] = 'cookie'

$cfg['Servers'][$i]['auth_type'] = 'config'

之间

$cfg['Servers'][$i]['connect_type'] = 'tcp'

$cfg['Servers'][$i]['connect_type'] = 'socket'

之间

$cfg['Servers'][$i]['AllowNoPassword'] = false

$cfg['Servers'][$i]['AllowNoPassword'] = true

之间

$cfg['Servers'][$i]['host'] = 'localhost'

$cfg['Servers'][$i]['host'] = '127.0.0.1'

似乎没有任何东西允许访问我的数据库。

目前,我收到登录屏幕和此错误:

2002 Cannot log in to the MySQL server

我应该改变什么?下面是我的 config.inc.php 文件:

<?php

$cfg['blowfish_secret'] = '89x7a3f';

$i = 0;

$i++;

$cfg['Servers'][$i]['auth_type'] = 'cookie';

$cfg['Servers'][$i]['host'] = 'localhost';

$cfg['Servers'][$i]['AllowRoot'] = true;

$cfg['Servers'][$i]['connect_type'] = 'tcp'; 

$cfg['Servers'][$i]['compress'] = true;

$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['AllowNoPassword'] = false;

$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'pass';

// $cfg['Servers'][$i]['controlhost'] = '';

$cfg['Servers'][$i]['controluser']   = 'pma';
$cfg['Servers'][$i]['controlpass']   = 'pmapass';

$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['DefaultConnectionCollation'] = 'utf8_general_ci';

$cfg['Servers'][$i]['table_uiprefs'] = 'pma_table_uiprefs';
$cfg['Servers'][$i]['tracking'] = 'pma_tracking';
$cfg['Servers'][$i]['designer_coords'] = 'pma_designer_coords';
$cfg['Servers'][$i]['userconfig'] = 'pma_userconfig';
$cfg['Servers'][$i]['recent'] = 'pma_recent';

// $cfg['Servers'][$i]['auth_swekey_config'] = '/etc/swekey-pma.conf';

$cfg['UploadDir'] = '';
$cfg['SaveDir'] = '';

$cfg['DefaultLang'] = 'en';


?>

最佳答案

如果您只需要访问您的数据库并且您知道您的登录凭据,请尝试使用管理员:

http://www.adminer.org/

它只是您放入 Web 服务器的单个 PHP 文件,并且没有 phpMyAdmin 那样的安全漏洞历史记录。我们已经用 MySQL 和 Postgres 上的 adminer 替换了所有 phpMyAdmin 安装,并且效果很好。

关于mysql - 无法通过phpMyAdmin访问数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18027666/

相关文章:

php - MySQL:比较两个表并列出新行?

mysql - 从mysql数据库获取数据

c# - C# 中的备用数据库连接

php - MySQL 在相对大的表(InnoDB)上添加索引

ios - 使用 Facebook iOS SDK 验证并登录我的应用程序

c# - HttpContext.Current.User.Identity.IsAuthenticated 返回 false

php - 在 phpmyadmin 中重置 ID

mysql - 使用 ID 从另一个表获取名称

php - 在这种情况下使用 Jquery 如何验证选择框?

android - TextField controlled controller.addListener(() 在使用 controller.clear 后被多次调用