php 在我的本地机器上安装 magento 后,我忘记了管理员密码

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16983227/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 12:01:24  来源:igfitidea点击:

after installing magento in my local machine I forgot admin password

phpmagentopassword-recovery

提问by Yavana

after installing magento in my local machine I forgot admin password what I have given. I am not able to login to my admin area how can I reset the password

在我的本地机器上安装 magento 后,我忘记了我提供的管理员密码。我无法登录到我的管理区域,我该如何重置密码

I have read this article http://www.atwix.com/magento/reset-admin-password-mysql/but it is not working for me. Or may be I am not getting this

我已经阅读了这篇文章http://www.atwix.com/magento/reset-admin-password-mysql/但它对我不起作用。或者可能是我没有得到这个

please help me am a beginner of Magento

请帮助我是 Magento 的初学者

回答by Mufaddal

Go To :

去 :

1 - Login in to PhpMyadmin .

1 - 登录到 PhpMyadmin。

2 - Jump in to Magento's database .

2 - 跳转到 Magento 的数据库。

3 - Go to admin_user table and edit the table .

3 - 转到 admin_user 表并编辑该表。

4 - put a "password" (which you want) and select MD5 from function dropdown (Important).

4 - 输入“密码”(您想要的)并从功能下拉列表中选择 MD5(重要)。

This is working both in CE And EE latest version (tested in both latest version), no need of core file changes.

这在 CE 和 EE 最新版本中都有效(在两个最新版本中都经过测试),无需更改核心文件。

回答by akkatracker

This would prove to be a good resource to read: http://www.magentocommerce.com/wiki/recover/resetting-admin-password

这将被证明是一个很好的阅读资源:http: //www.magentocommerce.com/wiki/recover/resetting-admin-password

SELECT * FROM admin_user;

Then, find the username you want to modify in the listing provided - ‘admin' in this example. Then, to update the password, type:

然后,在提供的列表中找到您要修改的用户名 - 在此示例中为“admin”。然后,要更新密码,请键入:

UPDATE admin_user SET password=CONCAT(MD5('qXpassword'), ':qX') WHERE username='admin';

‘qX' would be changed to whatever you want it to be and same goes for ‘password'

“qX”将更改为您想要的任何内容,“密码”也是如此

回答by John Yin

Mostly, when we install the Magento Community on our local computer (XAMPP, WAMPP), it looks like we can't log in as the administrator from the backend. The system will prompt us we input the wrong password, but it's not the truth.

大多数情况下,当我们在本地计算机(XAMPP、WAMPP)上安装 Magento 社区时,看起来我们无法从后端以管理员身份登录。系统会提示我们输入了错误的密码,但事实并非如此。

When i come up with this issue, i tried to reset the password by following method (in SQLyog).

当我提出这个问题时,我尝试通过以下方法(在 SQLyog 中)重置密码。

UPDATE admin_user 
SET password=CONCAT(MD5('qXpassword'), ':qX') 
WHERE username='admin';

‘password' should be set to whatever you want for your new password, and ‘qX' would be any random characters you like.

'password' 应设置为您想要的任何新密码,'qX' 将是您喜欢的任何随机字符。

But we still can not log in. At first, I thought this method is wrong method. While, the 'admin' password definitely had been changed. But why we still can not log in?

但是还是登陆不上,一开始以为这个方法不对。同时,“管理员”密码肯定已被更改。但是为什么我们仍然无法登录?

Maybe we have input the right user name and password, but we still can't log in.

可能我们输入了正确的用户名和密码,但是还是登陆不上。

Use Notepad ++ to open and edit core file: app/code/core/Mage/Core/Model/Session/Abstract/Varien.php, within your magento directory and comment those below lines:

使用 Notepad ++ 打开和编辑核心文件:app/code/core/Mage/Core/Model/Session/Abstract/Varien.php,在您的 magento 目录中,并注释以下行:

$cookieParams = array(
            'lifetime' => $cookie->getLifetime(),
            'path'     => $cookie->getPath() //,
            // 'domain'   => $cookie->getConfigDomain(),
            // 'secure'   => $cookie->isSecure(),
            // 'httponly' => $cookie->getHttponly()
        );

And try again, you should can log in as admin from the backend.

再试一次,您应该可以从后端以管理员身份登录。

The problem is Localhost or "127.0.0.1" are not true domains, and browsers allow only real domains to store cookies, that's why login stops and with invalid Username or Password.

问题是 Localhost 或“127.0.0.1”不是真正的域,浏览器只允许真正的域存储 cookie,这就是登录停止且用户名或密码无效的原因。

回答by Chris

The way I usually do it is as follows:

我通常的做法是这样的:

Add this snippet somewhere in your login.phtml template app/design/adminhtml/default/default/template/login.phtml

在 login.phtml 模板的某处添加这个片段 app/design/adminhtml/default/default/template/login.phtml

Mage::getSingleton('core/session', array('name' => 'adminhtml'));
$user = Mage::getModel('admin/user')->loadByUsername('YOUR_USERNAME');
$session = Mage::getSingleton('admin/session');
$session->setUser($user);

Replace 'YOUR_USERNAME' with your admin user name. Go to the login page (yourdomain.com/admin), now your admin session has been set. When you go to the login page again, you should be automatically logged in. Now you can reset your password in system > permissions > users.

将“YOUR_USERNAME”替换为您的管理员用户名。转到登录页面 (yourdomain.com/admin),现在您的管理会话已设置。当您再次进入登录页面时,您应该会自动登录。现在您可以在 中重置密码system > permissions > users

Don't forget to remove the snippet from your template once your are logged in.

登录后,不要忘记从模板中删除代码段。

It might not be the best answer but it has always worked for me.

这可能不是最好的答案,但它一直对我有用。

回答by Saustrup

Poking around in the database is a horrible idea, when you've got an entire framework at your fingertips. This is the proper way of changing the admin password:

当您拥有一个触手可及的整个框架时,在数据库中闲逛是一个可怕的想法。这是更改管理员密码的正确方法:

Create a file called reset-password.phpand place it in the site root:

创建一个名为的文件reset-password.php并将其放在站点根目录中:

<?php

chdir(dirname(__FILE__));
require 'app/Mage.php';
Mage::app('admin')->setUseSessionInUrl(false);
umask(0);

$user = Mage::getModel('admin/user')
    ->load('admin', 'username')
    ->setNewPassword('mynewpassword')
    ->save();

Make a request for /reset-password.phpin your browser, and the Magento framework should update the password for adminto mynewpassword.

/reset-password.php在您的浏览器中发出请求,Magento 框架应该更新adminto的密码mynewpassword

回答by BGuimberteau

This solution work for all versions of Magento.

此解决方案适用于所有版本的 Magento。

Add temporally this at end of index.php

在结束时临时添加 index.php

$user = Mage::getModel('admin/user')->loadByUsername('your_username');
$user->setPassword('new_password');
$user->save();

And your new_password was saved. Now remove 3 lines at the end of index.php.

您的 new_password 已保存。现在删除index.php.末尾的 3 行。

Have a nice day.

祝你今天过得愉快。

回答by khasru

To reset your admin password, you have to create a file and paste the bellow code into this file and upload it in your magento root directory.

要重置您的管理员密码,您必须创建一个文件并将以下代码粘贴到该文件中,然后将其上传到您的 magento 根目录中。

<?php
require_once 'app/Mage.php';
umask(0);
/* not Mage::run(); */
Mage::app('default');

## For magento1.7 or Earlier var
//$_HASH_SALT_LENGTH = 2;
## For magento1.8 and magento1.9
$_HASH_SALT_LENGTH = 32;

#Generate admin password
$password = "admin1234";
echo $adminPass = Mage::helper('core')->getHash($password, $_HASH_SALT_LENGTH);
## And reset password field in "admin_user" table

?>

And that's it, now you are able to login from admin using by this given password.

就是这样,现在您可以使用此给定密码从管理员登录。

For detail about reset admin password, Please go to my blog link http://www.scriptlodge.com/how-to-reset-admin-password-in-magento/

有关重置管理员密码的详细信息,请访问我的博客链接http://www.scriptlodge.com/how-to-reset-admin-password-in-magento/

回答by Rizwan

If you have access to phpMyAdmin, here are the steps to reset your password.

如果您有权访问 phpMyAdmin,这里是重置密码的步骤。

First, open up phpMyAdmin. Click on your database name for Magento from the sidebar on the left. Click on the SQL tab and type the following in to the text box:

首先,打开phpMyAdmin。从左侧边栏中单击 Magento 的数据库名称。单击 SQL 选项卡并在文本框中键入以下内容:

UPDATE `admin_user` SET `password` = MD5('PASSWORD') WHERE `username` = 'USERNAME';

You'll want to replace the capitalized values with the correct information:

您需要用正确的信息替换大写的值:

USERNAME - The user whose password you'll be udpating PASSWORD - The new password you want to use For example, if my username was admin and I wanted to reset the password to 123456, I would do this:

USERNAME - 您将更新其密码的用户 PASSWORD - 您要使用的新密码 例如,如果我的用户名是 admin 并且我想将密码重置为 123456,我会这样做:

UPDATE `admin_user` SET `password` = MD5('123456') WHERE `username` = 'admin';

If you don't know the name of the user you want to update, you can see all the users by clicking on the admin_user link from the sidebar, and then select the Browse tab. The username column has the list of available users.

如果您不知道要更新的用户的名称,您可以通过单击侧边栏中的 admin_user 链接查看所有用户,然后选择浏览选项卡。用户名列包含可用用户列表。

回答by Vinod VT

3 Steps without MySql

没有 MySql 的 3 个步骤

To login into magento admin, using only ftp access is a little tricky.

要登录 magento 管理员,仅使用 ftp 访问有点棘手。

Step 1 :

第1步 :

open the class Mage_Admin_Model_User located at app\code\core\Mage\Admin\Model\User.php.

打开位于 的 Mage_Admin_Model_User 类app\code\core\Mage\Admin\Model\User.php

Step 2 :

第2步 :

Next find the authenticate()function around line no: 225. Inside the authenticate function, this code is written,

接下来找到authenticate()周围的函数line no: 225。在authenticate函数里面,写了这段代码,

$this->loadByUsername($username);

You need to add the line return true;after this,

您需要return true;在此之后添加行,

$this->loadByUsername($username);
return true;

Step 3:

第 3 步

And that's it, now you login in admin using any password. Since, we have skipped the code for password checking, login using any password and then change the password in admin from

就是这样,现在您使用任何密码登录管理员。因为,我们跳过了密码检查的代码,使用任何密码登录,然后在 admin 中更改密码

System -> Permission -> Users.

System -> Permission -> Users.

回答by Pablo Molina

The cleanest way to fix this issue is to reset the Magento installation; be sure you keep details of your database credentials in a safe place:

解决此问题的最干净方法是重置 Magento 安装;确保将数据库凭据的详细信息保存在安全的地方:

  1. Delete local.xml in app\etc
  2. Delete \var\cache content
  3. Delete \var\session content
  4. Run the installation script in the browser with http://yourdomain/index.php
  5. Run the first screen (Localization)
  6. In the second screen, enable "Skip Base URL Validation Before the Next Step"
  7. Clean browser cache and cookies
  1. 删除 app\etc 中的 local.xml
  2. 删除 \var\cache 内容
  3. 删除 \var\session 内容
  4. 在浏览器中使用http://yourdomain/index.php运行安装脚本
  5. 运行第一个屏幕(本地化)
  6. 在第二个屏幕中,启用“在下一步之前跳过基本 URL 验证”
  7. 清理浏览器缓存和 cookie

Works 100% of the times.

工作 100% 的时间。