php 通过访问phpMyAdmin手动更改moodle管理员密码还是创建另一个管理员帐户?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10465637/
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
Manually change the moodle admin password with acces to phpMyAdmin or create another admin account?
提问by Trufa
The password for an admin login in a moodle platform is lost.
在moodle平台上的管理员登录密码丢失了。
I have access to the phpMyAdmin.
我可以访问 phpMyAdmin。
I went to the mdl_user table and there I can see or edit this table.
我去了 mdl_user 表,在那里我可以看到或编辑这个表。
How should I proceed? Can I change the admin encripted password and secret key to a known password or is it simpler to just add an admin user?
我应该如何进行?我可以将管理员加密的密码和密钥更改为已知密码还是仅添加管理员用户更简单?
How would that be?
那会怎样?
采纳答案by Trufa
Apparently Moodle version 1.9.9 only hashes the passwords with md5 once (with no salt at all!!).
显然,Moodle 1.9.9 版只使用 md5 对密码进行了一次哈希处理(完全没有盐!!)。
So the only thing to do is to replace the in the admin row the password filed with whatever password you want with a md5 applied.
因此,唯一要做的就是将管理行中的密码替换为您想要的任何密码,并应用 md5。
回答by Jerome Mouneyrac
only tested on Moodle 2
仅在 Moodle 2 上测试
You can reset any user password from command line. In your Moodle root:
您可以从命令行重置任何用户密码。在你的 Moodle 根中:
php admin/cli/reset_password.php
php admin/cli/reset_password.php
For dev prod environment you may also want to disable the password policy check (so you can enter a small and quick to type password). Edit reset_password.php and comment:
对于 dev prod 环境,您可能还想禁用密码策略检查(这样您就可以输入一个小而快速的密码)。编辑 reset_password.php 并注释:
// if (!check_password_policy($password, $errmsg)) {
// cli_error($errmsg);// }
// if (!check_password_policy($password, $errmsg)) {
// cli_error($errmsg);// }
回答by marxjohnson
Open up Moodle's config.php file, find the line where $CFG->passwordsaltmain is defined, and copy it's value (it's a long string of random characters).
打开Moodle的config.php文件,找到定义$CFG->passwordsaltmain的那一行,复制它的值(一长串随机字符)。
In PHPMyAdmin, run the following query, substituting values as appropriate:
在 PHPMyAdmin 中,运行以下查询,并根据需要替换值:
UPDATE mdl_user SET password = MD5(CONCAT('<new password>', '<password salt copied from config>')) WHERE id = <id of admin user>
回答by Omprakash Patel
HOW TO CHANGE THE PASSWORD USING MD5 HASH:
如何使用 MD5 哈希更改密码:
Log into phpMyAdmin. cPanel hosting will have a database utility called PhpMyAdmin within the cpanel. If the Moodle is installed on a non cPanel hosting, contact the hosting company for information on how to edit your database on the server. For more information on logging into PhpMyAdmin, please see the article on "How do I manage a MySQL database in PHPMyAdmin in my control panel (cpanel)?".
In PhpMyAdmin, find the table called mdl_user and select it. Since Moodle has many tables, the mdl_user table may be on the second page. Select the second page. Click the mdl_user table.
After selecting the table, find the table row for the user that is being edited. Click the Edit link with the pencil icon.
There will be a series of characters and numbers in the password field. This is an encrypted password so it cannot be viewed in the database. Replace the encrypted text with the new password for the login.
Next, in the drop down menu to the left, select MD5 then click Go.
登录 phpMyAdmin。cPanel 主机将在 cpanel 中有一个名为 PhpMyAdmin 的数据库实用程序。如果 Moodle 安装在非 cPanel 主机上,请联系主机公司以获取有关如何在服务器上编辑数据库的信息。有关登录 PhpMyAdmin 的更多信息,请参阅“如何在我的控制面板 (cpanel) 中的 PHPMyAdmin 中管理 MySQL 数据库?”一文。
在 PhpMyAdmin 中,找到名为 mdl_user 的表并选择它。由于 Moodle 有很多表,mdl_user 表可能在第二页。选择第二页。单击 mdl_user 表。
选择表格后,找到正在编辑的用户的表格行。单击带有铅笔图标的编辑链接。
密码字段中会有一系列字符和数字。这是一个加密密码,因此无法在数据库中查看。用新的登录密码替换加密文本。
接下来,在左侧的下拉菜单中,选择 MD5,然后单击 Go。
This can also be done for the Email address and the Username. The Email and the Username do not need the MD5 hash.
这也可以用于电子邮件地址和用户名。电子邮件和用户名不需要 MD5 哈希。
回答by Sandi Laufenberg-Deku
ANOTHER, MORE QUICK AND EASY WAY TO GENERATE A NEW MD5 HASH PASSWORD:
生成新的 MD5 哈希密码的另一种更快速、更简单的方法:
- Go to http://www.miraclesalad.com/webtools/md5.phpand create a new password like... wintersnow123~ (it will look like this: "003df036e1a99aad3eaba7c3ca46723d" without quotes).
- Copy the md5 hash password generated from the word you submitted (it's easy) and be prepared to paste it.
- Using phpMyAdmin, log into your MySQL database.
- Navigate to the user table (for Moodle, it's called "mdl_user") and browse the data.
- When you find the "admin" user account, click on edit, and paste in the new password you copied in Step 2 ("003df036e1a99aad3eaba7c3ca46723d"). (Into the password field.) This will replace what you had previously.
- Try logging in with your admin user account and the new password (Password: wintersnow123~)
- 转到http://www.miraclesalad.com/webtools/md5.php并创建一个新密码,如... Wintersnow123~(它看起来像这样:“003df036e1a99aad3eaba7c3ca46723d”,不带引号)。
- 复制从您提交的单词生成的 md5 哈希密码(很容易)并准备粘贴它。
- 使用 phpMyAdmin,登录到您的 MySQL 数据库。
- 导航到用户表(对于 Moodle,它称为“mdl_user”)并浏览数据。
- 当您找到“admin”用户帐户时,单击编辑,然后粘贴您在第 2 步中复制的新密码(“003df036e1a99aad3eaba7c3ca46723d”)。(进入密码字段。)这将替换您之前的内容。
- 尝试使用您的管理员用户帐户和新密码登录(密码:wintersnow123~)
回答by Zombaya
You could just check the sourcecode and see how the hash is calculated. You could then make a new hash with your new password with their hashing-function.
您可以查看源代码并查看哈希是如何计算的。然后你可以用你的新密码和他们的散列函数创建一个新的散列。
I checked the source-codeand depending on the configuration, its hashed with md5 or sha1. So check your config and make a hash of your own.
我检查了源代码,根据配置,它用 md5 或 sha1 散列。因此,请检查您的配置并创建您自己的哈希。
// From the sourcecode:
if ($this->config->passtype === 'md5') { // Re-format password accordingly
$extpassword = md5($extpassword);
} else if ($this->config->passtype === 'sha1') {
$extpassword = sha1($extpassword);
}
回答by edelgado
Currently Moodle introduces a salt in passwords to uniquely encrypt passwords in each installation.
目前 Moodle 在密码中引入了 salt 来唯一地加密每个安装中的密码。
If you didn't delete or changed guest account password you can copy its value to admin user password to be able to login.
如果您没有删除或更改访客帐户密码,您可以将其值复制到管理员用户密码以便能够登录。
Later you can change it to whatever you like.
稍后您可以将其更改为您喜欢的任何内容。
User accounts are stored mdl_user table.
用户帐户存储在 mdl_user 表中。

