macos 使用 XAMPP 在 Mac 上的 phpMyAdmin 中更改密码,现在无法访问 localhost/phpmyadmin
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10574568/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Changed password in phpMyAdmin on a Mac using XAMPP, now unable to access localhost/phpmyadmin
提问by Chris Sellers
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.
我已经阅读了我能找到的所有关于此的帖子,但没有任何帮助。我已经从我的电脑中删除了 XAMPP 文件夹,并从 DMG 文件中重新安装了它,这当然解决了问题,但我想知道将来如何修复它。
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.
一切如何开始:我在我的 Macbook(运行 Mac OS X v10.7.4)上登录到 phpMyAdmin。我看到消息建议我更改root的密码,默认情况下没有密码。我转到“管理权限”选项卡并更改了 localhost、webdev 和 127.0.0.1 上 root 的密码。在每种情况下,我都输入相同的短密码并单击“生成密码”,这会创建三个不同的哈希值。
You know what comes next: When I tried to access localhost/phpmyadmin again, I was locked out with the message:
你知道接下来会发生什么:当我再次尝试访问 localhost/phpmyadmin 时,我被以下消息锁定:
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.
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,它建议我在命令行中设置 root 的密码。我在我的用户目录中创建了一个“.profile”文件,其中包含“export PATH=/opt/local/bin:/opt/local/sbin:/Applications/xampp/xamppfiles/bin:$PATH”。这使我能够开始一个 mysql 会话,但是(作为一个菜鸟)我不知道在那之后该怎么做。
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
Stackoverflow 还建议我可以在 config.inc.php 中更改密码。我在 phpmyadmin/setup/frames/config.inc.php 找到了这个文件,但是
$cfg['Servers'][$i]['password'] = '';
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.
不在那里。我确实在 phpmyadmin/libraries/config.default.php 中找到了该行,但该文件包含针对编辑它的可怕警告。我发现了另一个可能的文件,phpmyadmin/setup/lib/common.inc.php,以及 phpmyadmin/scripts/signon.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.
我确定这是一个新手错误,或者其中几个错误,但我很好奇地发现我在 stackoverflow 上查找的所有内容都没有帮助我。我还希望 Mac OS 能够更轻松地执行诸如创建系统文件(例如,.profile)和编辑 XAMPP 文件(例如,common.inc.php)之类的操作。但你能做什么呢。
回答by bool.dev
In your main installation folder for phpMyAdmin, you must have made a config.inc.phpfile, that is the file that you should be changing. Incase you don't have that file, then create it:
在 phpMyAdmin 的主安装文件夹中,您必须创建一个config.inc.php文件,该文件是您应该更改的文件。如果您没有该文件,请创建它:
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):
在主安装文件夹 (pMA) 中,您已经有一个名为config.sample.inc.php的文件,其中包含默认配置。复制此文件并将其重命名为config.inc.php,您可以直接使用cp
命令执行此操作(导航到所述文件夹后):
cp ./config.sample.inc.php ./config.inc.php
Now make a few changes to this new file:
现在对这个新文件进行一些更改:
- 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) - Write/change this line:
$cfg['Servers'][$i]['AllowNoPassword'] = false;
- 将条目更改
$cfg['Servers'][$i]['host'] = 'localhost';
为$cfg['Servers'][$i]['host'] = '127.0.0.1';
(因为它在某些地方不起作用) - 写入/更改此行:
$cfg['Servers'][$i]['AllowNoPassword'] = false;
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
注意:phpMyAdmin 的主安装文件夹是指安装 phpMyAdmin 的根文件夹,即/<abc>/<xyz>/phpMyAdmin/
.
还要先进行第二次更改,只有在找不到主机的情况下才进行第一次更改
回答by kmt
Inside \xampp\phpmyadmin\config_inc.php
里面 \xampp\phpmyadmin\config_inc.php
add or change like following code.$cfg['Servers'][$i]['auth_type'] = 'cookie';
添加或更改如下代码。$cfg['Servers'][$i]['auth_type'] = 'cookie';
after that try to clear browsing data. then restart mysql.
It works for me. Hope it may help you.
之后尝试清除浏览数据。然后重启mysql。
这个对我有用。希望它可以帮助你。
回答by Gaurav Sarma
Although, @bool dev have provided an answer above. I would like to share my version of how i resolved this using the terminal. I am using 10.12.5 (OS Serria)
虽然,@bool dev 已经在上面提供了答案。我想分享我如何使用终端解决这个问题的版本。我正在使用 10.12.5 (OS Serria)
Firstly, you need to have root access
首先,你需要有root权限
sudo su
Then go to root folder
然后进入根文件夹
cd /
From there you need to navigate to the phpMyAdmin folder
从那里您需要导航到 phpMyAdmin 文件夹
cd Applications/XAMPP/xamppfiles/phpmyadmin/
Then using any editor open the config.inc.php file. (I used vi)
然后使用任何编辑器打开 config.inc.php 文件。(我用的是vi)
vi config.inc.php
Go to the following section in the file
转到文件中的以下部分
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = ''; // This is empty, set your password here
Then just restart your MySql server. And viola it should be working now.
然后只需重新启动您的 MySql 服务器。中提琴现在应该可以工作了。