This is a translated page. The original can be found here: http://iwebdevel.com/2009/06/08/wordpress-easily-reset-your-account-password-using-mysql-and-php/
UPDATES VIA RSS | Email CẬP NHẬT VIA RSS | Email Get updates via feedburner Get updates via twitter
Home / Coding / MySQL / PHP / Wordpress: Easily Reset Your… Trang chủ / Coding / MySQL / PHP / Wordpress: Dễ dàng Reset của bạn ...

Wordpress: Easily Reset Your Account Password Using MySQL and PHP Wordpress: Dễ dàng Đặt lại mật khẩu tài khoản của bạn Sử dụng MySQL và PHP

Posted on 08. Được đăng trên 08. Jun, 2009 by Dragos in Coding , MySQL , PHP Tháng Sáu, 2009 bởi Dragos tại Coding, MySQL, PHP

I've just forgot my admin password on my local testing blog, and what is worse – my local machine is not configured to send external email. Tôi đã chỉ quên mật khẩu quản trị của mình trên blog thử nghiệm địa phương của tôi, và những gì tồi tệ hơn - máy địa phương của tôi không được cấu hình để gửi thư điện tử bên ngoài. Oh yeah, got to reinstall wordpress again, what a pity. Oh yeah, đã cài đặt lại wordpress lần nữa, những gì a pity. No way! No way! There are two ways of resetting your password using two easy methods. Có hai cách để đặt lại mật khẩu của bạn bằng cách sử dụng hai phương pháp dễ dàng. You'll need basic knowledge of PHP or CPanel+PHPMyAdmin. Bạn sẽ cần những kiến thức cơ bản về PHP hoặc cPanel + PHPMyAdmin.

I Method: CPanel+PHPMyAdmin Tôi Phương pháp: cPanel + PHPMyAdmin

For this method, it is necessary that your host have CPanel and PHPMyAdmin installed. Đối với phương pháp này, cần có máy chủ lưu trữ của bạn có CPanel và PHPMyAdmin cài đặt. If your host doesn't have these pieces of software, but something similar to these, you can follow this tutorial and apply these steps to your situation. Nếu máy chủ của bạn không có những miếng của phần mềm, nhưng cái gì tương tự như này, bạn có thể làm theo hướng dẫn này và áp dụng các bước sau để tình hình của bạn.

First we'll need to open the PHPMyAdmin page. Trước tiên, chúng tôi sẽ cần phải mở trang PHPMyAdmin. From the CPanel root page, launch PHPMyAdmin. Từ trang gốc CPanel, chạy PHPMyAdmin. The icon of PHPMyAdmin should look similar to the one emphasized in the screenshot below. Biểu tượng của PHPMyAdmin nên trông giống như một sự nhấn mạnh trong hình dưới đây.

PHPMyAdmin

PHPMyAdmin PHPMyAdmin

Once on the main page of PHPMyAdmin you should remember what database did you use when installing wordpress. Sau khi trên trang chính của PHPMyAdmin bạn nên nhớ những gì cơ sở dữ liệu bạn đã sử dụng khi cài đặt wordpress. If you don't remember, don't get angry. Nếu bạn không nhớ, không nhận được giận dữ. Go to your root folder where wordpress is installed and download & open the file wp-config.php with a simple text editor like Notepad/GEdit. Vào thư mục gốc của bạn, nơi wordpress được cài đặt và tải về & mở file wp-config.php với một trình soạn thảo văn bản đơn giản như Notepad / gedit. You'll need to find this line: Bạn sẽ cần phải tìm dòng này:

 define('DB_NAME', 'ABCD'); define ( 'db_name', 'ABCD'); 

Note that ABCD (without the single quotes around it) is the name of the database that wordpress is installed in. Lưu ý rằng ABCD (không có dấu nháy đơn xung quanh nó) là tên của cơ sở dữ liệu đó được cài đặt wordpress in

Back on the PHPMyAdmin page, click on the link of your database name. Quay lại trên trang PHPMyAdmin, nhấp vào liên kết của tên cơ sở dữ liệu của bạn. In my case it was _iwebdevel . Trong trường hợp của tôi nó đã được _iwebdevel.

Select your database

Select your database Chọn cơ sở dữ liệu của bạn

Now you'll see another PHPMyAdmin page, but this time you'll be presented all your tables contained in the ABCD database. Bây giờ bạn sẽ thấy một trang PHPMyAdmin, nhưng thời gian này bạn sẽ được trình bày tất cả các bảng chứa trong cơ sở dữ liệu ABCD. We need to select the table users . Chúng ta cần phải chọn người sử dụng bảng. You won't see the exact name users of this table, but a name in this format xx_users , where xx_ is the prefix of your wordpress table names. Bạn sẽ không thấy người dùng tên chính xác của bảng này, nhưng một tên trong xx_users định dạng, nơi xx_ là tiền tố của tên bảng wordpress của bạn. Click on the link of your users table ( xx_users ). Nhấp vào liên kết của bảng người dùng của bạn (xx_users). In my case, as in most cases it's wp_users : Trong trường hợp của tôi, như trong phần lớn trường hợp nó wp_users:

Select the users table

Select the users table Chọn bảng người dùng

Now click on browse to see the rows contained in table xx_users . Now click on duyệt để xem các hàng chứa trong xx_users bảng.

Click on browse

Click on browse Nhấp vào duyệt

Now look for the username you want to reset the password. Bây giờ hãy tìm tên người bạn muốn đặt lại mật khẩu. In my case I want to reset password for admin. Now click on the edit button. Trong trường hợp của tôi tôi muốn đặt lại mật khẩu cho admin. Now click vào nút chỉnh sửa.

Edit user's details

Edit user's details Hiệu chỉnh người sử dụng của các chi tiết

Now you'll need to generate an MD5 hash of the new password you would like to set. Bây giờ bạn sẽ cần phải tạo ra một MD5 của mật khẩu mới bạn muốn thiết lập. Go to http://seoanalytic.com/tools/md5_encryptor/ and enter your preferred password. Vào http://seoanalytic.com/tools/md5_encryptor/ và nhập mật khẩu ưa thích của bạn. After you enter your new password, click on the Encrypt! button. Sau khi bạn nhập mật khẩu mới của bạn, hãy nhấp vào nút! Mã hoá.

Encrypt your password

Encrypt your password Mã hóa mật khẩu của bạn

After you've encrypted your password, select and copy the newly MD5 generated hash code. Sau khi bạn đã được mã hóa mật khẩu của bạn, chọn và sao chép vừa được tạo ra mã MD5 băm.

Select and copy the MD5 hash

Select and copy the MD5 hash Chọn và sao chép MD5

Now return to your PHPMyAdmin page and paste your MD5 hash from the clipboard to the input field as shown in the image below: Bây giờ trở về trang PHPMyAdmin của bạn và dán MD5 của bạn từ clipboard vào trường đầu vào như trong hình dưới đây:

Paste MD5 hash in the specified input field

Paste MD5 hash in the specified input field Dán MD5 băm trong lĩnh vực đầu vào quy định

Finally click on Go button to save your new password. Cuối cùng nhấn vào nút Go để lưu mật khẩu mới của bạn.

Save new password

Save new password Lưu mật khẩu mới

II Method: PHP II Phương pháp: PHP

In my opinion the second method is much faster and simpler. Theo tôi phương pháp thứ hai là nhanh hơn và đơn giản. In this method you'll just have to upload a PHP file to your host and access it with a browser. Trong phương pháp này bạn sẽ chỉ phải tải lên một tập tin PHP để lưu trữ của bạn và truy cập nó với một trình duyệt. But we'll talk about it a little bit later. Nhưng chúng tôi sẽ nói về nó một chút sau đó.

So here's the piece of PHP code I've came up with to help you reset your wordpress account password. Vì vậy, đây là đoạn mã PHP tôi đã đến với để giúp bạn khôi phục mật khẩu tài khoản wordpress của bạn.

  $newPassword='NEW_PASSWORD_GOES_HERE'; //put your new password between the single quotes $ Newpassword = 'NEW_PASSWORD_GOES_HERE'; / / đặt mật khẩu mới giữa các dấu nháy đơn
	$username='admin'; //put the login username you'd like to change the password to $ username = 'admin'; / / đặt tên người dùng đăng nhập, bạn muốn thay đổi mật khẩu để
	@include_once('./wp-config.php'); //get some details from your wordpress installation @ include_once ( '/ wp.-config.php'); / / nhận được từ một số chi tiết của bạn cài đặt wordpress
	global $table_prefix; global $ table_prefix;
	$conxb=mysql_connect(DB_HOST,DB_USER,DB_PASSWORD); //establish connection to your database $ conxb = mysql_connect (DB_HOST, DB_USER, DB_PASSWORD); / / thiết lập kết nối với cơ sở dữ liệu của bạn
	mysql_select_db(DB_NAME,$conxb); mysql_select_db (db_name, $ conxb);
	$query='update `'.$table_prefix.'users` set `user_pass`=\''.mysql_real_escape_string(md5($newPassword)).'\' where `user_login`=\''.mysql_real_escape_string($username).'\' limit 1'; $ query = 'Cập nhật `' $ table_prefix.. 'người sử dụng thiết` `user_pass` = \''mysql_real_escape_string (md5 ($ Newpassword))..' \ 'nơi `user_login` = \''. mysql_real_escape_string ($ username). '\' giới hạn 1 ';
	$mQuery=mysql_query($query,$conxb); //set new password $ mQuery = mysql_query ($ query conxb); / / thiết lập mật khẩu mới
	echo $mQuery?'Successfully set new password. echo $ mQuery? 'thành công thiết lập mật khẩu mới. New password: '.$newPassword:'There was an error. Mật khẩu mới: '. $ Newpassword:' Có một lỗi. Error: '.mysql_error(); //if result is unsuccessful you'll see the mysql error message Mysql_error. Lỗi: '(); / / nếu kết quả là không thành công, bạn sẽ thấy thông báo lỗi mysql
	mysql_close($conxb); mysql_close ($ conxb); 

For your convenience you can download the file reset.php from here . Để thuận tiện của bạn, bạn có thể tải các tập tin từ reset.php ở đây.

Now extract the zip archive you've just downloaded and edit the necessary parameters to suit your needs (explanation comments are present in the PHP code above). Bây giờ giải nén lưu trữ zip bạn vừa tải về và chỉnh sửa các thông số cần thiết cho phù hợp với nhu cầu của bạn (ý kiến giải thích được hiện diện trong mã PHP ở trên). Then upload the file reset.php to your wordpress root installation folder. Sau đó, tải lên các reset.php tập tin để cài đặt wordpress thư mục gốc của bạn. To make sure that this is the right directory, look for a file named wp-config.php , Để chắc chắn rằng điều này là thư mục bên phải, hãy tìm một tập tin tên là wp-config.php, if it's there you're on the right way, else look for the directory where wp-config.php is present and upload the file reset.php there. nếu nó có bạn đang trên con đường bên phải, tìm các thư mục khác, nơi wp-config.php là hiện tại và tải lên những tập tin có reset.php.

Finally you'll want to go to http://yourDomainName.TLD/ reset.php . Cuối cùng bạn sẽ muốn đi đến http://yourDomainName.TLD/ reset.php. You'll see the appropriate message depending on how the script worked. Bạn sẽ nhìn thấy thông báo thích hợp tùy thuộc vào cách kịch bản làm việc. If there is an error, post it here and I'll try to help you, else you did everything perfectly and you can now log in with your new password. Nếu có một lỗi, đăng nó ở đây và tôi sẽ cố gắng giúp bạn, bạn đã làm tất cả mọi thứ khác hoàn hảo và bây giờ bạn có thể đăng nhập bằng mật khẩu mới của bạn.

Translate this post Dịch bài đăng này


Related posts: Liên quan đến bài viết:

  1. Wordpress 2.8.4: Not ready to be installed with PHP 5.3 ? Wordpress 2.8.4: Chưa sẵn sàng được cài đặt với PHP 5,3?
  2. Wordpress: Best SEO iTranslator for Wordpress, get free traffic from fully automated plugin script Wordpress: Best SEO iTranslator cho Wordpress, nhận được lưu lượng truy cập miễn phí từ kịch bản plugin hoàn toàn tự động
  3. PHP: How to get creation time of file with PHP on Linux machines PHP: Làm thế nào để có được thời gian tạo ra các tập tin với PHP trên máy Linux
  4. Coding:How to fetch user profile data with SSI.php from a SMF forum database Coding: Làm thế nào để lấy dữ liệu hồ sơ người dùng với SSI.php từ một cơ sở dữ liệu diễn đàn SMF
  5. PHP Error: Call to a member function fetch_assoc() on a non-object in PHP Error: Gọi đến một thành viên năng fetch_assoc () trên một phi vật thể tại

  • Katya Katya
    :) :)
  • purie purie
    i have to try but why does still there error ? tôi đã thử, nhưng tại sao vẫn có lỗi? when i would to login.. khi tôi để xin đăng nhập .. cann`t read the password .. cann `t đọc được mật khẩu ..
    could you tell why does my code still error. bạn có thể cho biết tại sao mã của tôi vẫn còn lỗi. thank you cảm ơn bạn
blog comments powered by Disqus blog ý kiến được hỗ trợ bởi are On