使用 XAMPP 在 Mac 上更改 phpMyAdmin 中的密码,现在无法访问 localhost/phpmyadmin [英] Changed password in phpMyAdmin on a Mac using XAMPP, now unable to access localhost/phpmyadmin

查看:24
本文介绍了使用 XAMPP 在 Mac 上更改 phpMyAdmin 中的密码,现在无法访问 localhost/phpmyadmin的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读了所有我能找到的关于此的帖子,但没有任何帮助.我已经从我的计算机中删除了 XAMPP 文件夹并从 DMG 文件中重新安装它,这当然解决了问题,但我想知道将来如何解决它.

I've read all the posts I could find about this, and none helped. I've deleted the XAMPP folder from my computer and reinstalled it from the DMG file, which of course fixed the problem, but I'd like to know how to fix it in the future.

这一切是如何开始的:我在我的 Macbook(运行 Mac OS X v10.7.4)上登录了 phpMyAdmin.我看到提示我更改root密码的消息,默认情况下没有密码.我转到管理权限选项卡并更改了 localhost、webdev 和 127.0.0.1 上的 root 密码.在每种情况下,我都输入了相同的短密码并单击生成密码",这会创建三个不同的哈希值.

How it all started: I was logged in to phpMyAdmin on my Macbook (which runs Mac OS X v10.7.4). I saw the message advising me to change the password of root, which by default has no password. I went to the Manage Privileges tab and changed the password for root on localhosts, webdev and 127.0.0.1. In each case, I typed in the same short password and clicked "Generate Password," which created three different hashes.

你知道接下来会发生什么:当我再次尝试访问 localhost/phpmyadmin 时,我被以下消息锁定:

You know what comes next: When I tried to access localhost/phpmyadmin again, I was locked out with the message:

Error

MySQL said: 

#1045 - Access denied for user 'root'@'localhost' (using password: NO) 

phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection.  You should check the host, username and password in your configuration and make sure that  they correspond to the information given by the administrator of the MySQL server. 

所以我查看了stackoverflow,它建议我在命令行中设置root 的密码.我在我的用户目录中创建了一个.profile"文件,其中包含export PATH=/opt/local/bin:/opt/local/sbin:/Applications/xampp/xamppfiles/bin:$PATH".这使我能够启动一个 mysql 会话,但是(作为一个菜鸟)我不知道在那之后该怎么做.

So I looked up stackoverflow, which advised me to set the password for root at the command line. I created a ".profile" file in my user directory, with "export PATH=/opt/local/bin:/opt/local/sbin:/Applications/xampp/xamppfiles/bin:$PATH" in it. That enabled me to start a mysql session, but (being a noob) I couldn't figure out what to do after that.

Stackoverflow 还建议我可以更改 config.inc.php 中的密码.我在 phpmyadmin/setup/frames/config.inc.php 找到了这个文件,但是

Stackoverflow also advised that I could change the password in config.inc.php. I found this file at phpmyadmin/setup/frames/config.inc.php, but the line

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

不在那里.我确实在 phpmyadmin/libraries/config.default.php 中找到了该行,但该文件包含对编辑它的可怕警告.我发现了另一个可能的文件,phpmyadmin/setup/lib/common.inc.php,以及 phpmyadmin/scripts/signon.php,但在所有情况下,我的计算机都阻止我进行任何更改,说我没有权限.所以这很令人沮丧.

was not in there. I did find that line in phpmyadmin/libraries/config.default.php, but that file contains dire warnings against editing it. I found another likely file, phpmyadmin/setup/lib/common.inc.php, as well as phpmyadmin/scripts/signon.php, but in all cases, my computer prevented me from making any changes, saying I didn't have permissions. So that was frustrating.

我确定这是一个新手错误,或者其中几个错误,但我很好奇地发现我在 stackoverflow 上查找的所有内容都没有帮助我.我还希望 Mac OS 能够更轻松地创建系统文件(例如 .profile)和编辑 XAMPP 文件(例如 common.inc.php).但你能做什么呢.

I'm sure this is a rookie mistake, or several of them, but I was curious to find that none of the things I looked up on stackoverflow helped me. I also wish the Mac OS made it easier to do things like create system files (e.g., .profile) and edit XAMPP files (e.g., common.inc.php). But what can you do.

推荐答案

在您的 phpMyAdmin 主安装文件夹中,您必须创建一个 config.inc.php 文件,即您安装的文件应该改变.如果您没有该文件,请创建它:

In your main installation folder for phpMyAdmin, you must have made a config.inc.php file, that is the file that you should be changing. Incase you don't have that file, then create it:

在主安装文件夹(pMA)中,您已经有一个名为:config.sample.inc.php 的文件,其中包含默认配置.复制此文件并将其重命名为 config.inc.php,您可以直接使用 cp 命令(在导航到上述文件夹后):

In the main installation folder(pMA) you would already have a file named: config.sample.inc.php, which contains the default configurations. Make a copy of this file and rename it to config.inc.php, you can do that directly using cp command (after navigating into the said folder):

cp ./config.sample.inc.php ./config.inc.php

现在对这个新文件进行一些更改:

Now make a few changes to this new file:

  1. 将条目 $cfg['Servers'][$i]['host'] = 'localhost'; 更改为 $cfg['Servers'][$i]['host'] = '127.0.0.1';(因为它在某些地方不起作用)
  2. 编写/更改此行:$cfg['Servers'][$i]['AllowNoPassword'] = false;
  1. Change the entry $cfg['Servers'][$i]['host'] = 'localhost'; to $cfg['Servers'][$i]['host'] = '127.0.0.1'; (as it does not work in some places)
  2. Write/change this line: $cfg['Servers'][$i]['AllowNoPassword'] = false;

注意:phpMyAdmin的主安装文件夹是指phpMyAdmin安装的根文件夹,即/<abc>/<xyz>/phpMyAdmin/.
同样先进行第二次更改,只有在没有找到主机时才进行第一次更改

Note: by the main installation folder for phpMyAdmin i mean the root folder of the installation of phpMyAdmin, i.e /<abc>/<xyz>/phpMyAdmin/.
Also make the 2nd change first, and make the 1st change only if the host is not found

这篇关于使用 XAMPP 在 Mac 上更改 phpMyAdmin 中的密码,现在无法访问 localhost/phpmyadmin的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆