Change and Reset MySQL root Password Thay đổi và Thiết lập lại mật khẩu root MySQL
Other then the ways specified Khác sau đó là cách xác định here ở đây to reset and change the root password for mySQL database in the case that the password is forgotten or lost, the following instructions explain in details the alternative way at the last part of the guide, where no additional file needs to be created: để thiết lập lại và thay đổi mật khẩu chủ cho các cơ sở dữ liệu mySQL trong trường hợp đó là quên mật khẩu hoặc mất, các hướng dẫn sau đây giải thích chi tiết các cách khác ở phần cuối của hướng dẫn, nơi không có tập tin bổ sung cần phải được tạo ra:
- Login as root to the Windows or Unix-like (Unix, Linux or BSD) machine with the MySQL server. Đăng nhập như là người chủ của Windows hoặc * nix (Unix, Linux hay BSD) máy với máy chủ MySQL.
- Stop the MySQL server by using either of the following command: Ngừng máy chủ MySQL bằng cách sử dụng một trong hai lệnh sau đây:
Linux: /etc/rc.d/init.d/mysql stop Linux: / etc / rc.d / init.d / mysql stop
FreeBSD: /usr/local/etc/rc.d/mysql-server.sh stop FreeBSD: / usr / local / etc / rc.d / mysql-server.sh dừng - Open the mysql server startup script (ie mysql-server.sh – the file executed to start or stop MySQL server. Mở các tập lệnh khởi động máy chủ mysql (tức là mysql-server.sh - file thực thi để bắt đầu hoặc ngừng máy chủ MySQL.
- Add –skip-grant-tables to the end of the line that contains the mysqld_safe command as its parameter. Add-skip-cấp-bàn đến hết dòng chứa lệnh mysqld_safe như tham số của nó.
- Start MySQL server with the following command: Bắt đầu máy chủ MySQL với lệnh sau đây:
Linux: /etc/rc.d/init.d/mysql start Linux: / etc / rc.d / init.d / mysql start
FreeBSD: /usr/local/etc/rc.d/mysql-server.sh start FreeBSD: / usr / local / etc / rc.d / mysql-server.sh bắt đầu - Alternatively, start the MySQL server directly and skip the editing with the following command: Ngoài ra, bắt đầu các máy chủ MySQL trực tiếp và bỏ qua chỉnh sửa với lệnh sau đây:
mysqld_safe –skip-grant-tables & mysqld_safe-skip-grant-tables &
Depending on your path environment, you may need to point to the correct directory where mysqld_safe is instead. Tùy thuộc vào môi trường đường dẫn của bạn, bạn có thể cần để trỏ đến các thư mục chính xác nơi mysqld_safe được thay thế.
- Run the following commands to login as the mysql user and connect to mysql user/permission database: Chạy các lệnh sau đây để đăng nhập như là người sử dụng mysql và kết nối với người sử dụng mysql / cơ sở dữ liệu cho phép:
# mysql -u root mysql # Mysql-u root mysql
- Run the update queries to change the MySQL password: Khởi động cập nhật các truy vấn để thay đổi mật khẩu MySQL:
mysql> UPDATE user SET Password=PASSWORD('newrootpassword') WHERE User='root'; mysql> UPDATE user SET Password = PASSWORD ( 'newrootpassword') WHERE User = 'root';
mysql> FLUSH PRIVILEGES; mysql> FLUSH PRIVILEGES;Note: Replace newrootpassword with the new root password for MySQL server. Lưu ý: Thay thế newrootpassword với mật khẩu chủ mới cho máy chủ MySQL. Flush Privileges is needed to making the password change effect immediately. Xóa đặc quyền là cần thiết để thực hiện các thay đổi mật khẩu có hiệu lực ngay lập tức.
- Exit mysql database client by typing exit. Thoát khỏi mysql cơ sở dữ liệu khách hàng bằng cách nhập xuất cảnh.
- Stop MySQL server with commands listed at step 2. Ngừng máy chủ MySQL với các lệnh được liệt kê ở bước 2.
- Open the mysql server startup script edit in step 3 again and remove the –skip-grant-tables parameter that has been added. Mở máy chủ mysql khởi động kịch bản sửa trong bước 3 lần nữa và loại bỏ các-skip-cấp-bảng thông số đó đã được thêm.
- Start MySQL server by using command from step 5 or 6. Bắt đầu bằng cách sử dụng máy chủ MySQL lệnh từ bước 5 hoặc 6.
For Redhat Linux users, use the following instructions as the root user of Redhat Linux machine: Đối với người dùng Linux Redhat, sử dụng các hướng dẫn sau đây như là người dùng gốc của máy Redhat Linux:
- Stop MySQL process by using command: Stop MySQL quá trình bằng cách sử dụng lệnh:
# killall mysqld # Killall mysqld
- Start the MySQL server with following options: Bắt đầu máy chủ MySQL với các tùy chọn sau đây:
# /usr/libexec/mysqld -Sg –user=root & # / Usr / libexec / mysqld-Vn-user = root &
- Start the MySQL client: Bắt đầu các khách hàng MySQL:
# mysql # Mysql
You should see the following message: Bạn sẽ thấy thông điệp sau đây:
Welcome to the MySQL monitor. Chào mừng đến với màn hình MySQL. Commands end with ; or g. Lệnh kết thúc bằng; hoặc g.
Your MySQL connection id is 1 to server version: 3.xx.xx MySQL id của bạn là 1 kết nối đến máy chủ phiên bản: 3.xx.xxType 'help;' or 'h' for help. Loại 'giúp đỡ;' hoặc 'h' để được giúp đỡ. Type 'c' to clear the buffer. Type 'c' để xóa bộ đệm.
mysql> mysql>
- Use mysql database: Sử dụng cơ sở dữ liệu mysql:
mysql> USE mysql mysql> USE mysql
You should see the following message: Bạn sẽ thấy thông điệp sau đây:
Reading table information for completion of table and column names Đọc thông tin bảng để hoàn thành bảng và cột tên
You can turn off this feature to get a quicker startup with -A Bạn có thể tắt tính năng này để có được một khởi động nhanh hơn với-ADatabase changed Cơ sở dữ liệu thay đổi
- Then, update the password for the root user with the following command: Sau đó, cập nhật mật khẩu cho người dùng root với lệnh sau đây:
UPDATE user SET password=password(”newpassword”) WHERE user=”root”; UPDATE mật khẩu Set user = mật khẩu ( "Newpassword") WHERE user = "root";
Replace newpassword with your desired password. Thay thế Newpassword với mật khẩu mong muốn của bạn. You should see the following message: Bạn sẽ thấy thông điệp sau đây:
Query OK, 2 rows affected (0.03 sec) Query OK, 2 hàng bị ảnh hưởng (0,03 giây)
Rows matched: 2 Changed: 2 Warnings: 0 Rows matched: 2 Changed: 2 Warnings: 0Rows affected may be different, but the Query OK should be there. Hàng bị ảnh hưởng có thể khác nhau, nhưng OK Truy vấn nên có.
- Flush the database privileges to reload it in order to make the changes effective: Tuôn ra những đặc quyền cơ sở dữ liệu để tải lại nó để thực hiện những thay đổi có hiệu quả:
mysql> flush privileges; mysql> flush privileges;
You should get the following result: Bạn sẽ nhận được kết quả như sau:
Query OK, 0 rows affected (0.02 sec) Query OK, 0 hàng bị ảnh hưởng (0,02 giây)
- Exit the MySQL client by typing exit. Thoát khỏi các khách hàng bằng cách gõ MySQL thoát.
- Kill the MySQL server process by typing killall mysqld. Giết chết quá trình máy chủ MySQL bằng cách gõ killall mysqld.
- Then start MySQL again: Sau đó bắt đầu MySQL một lần nữa:
/etc/init.d/mysqld start / etc / init.d / mysqld start
IMPORTANT : The page is machine translated and provided "as is" without warranty. Quan trọng: Sửa là máy dịch và cung cấp "như là" không có bảo hành. Machine translation may be difficult to understand. Máy dịch thuật có thể khó hiểu. Please refer to Vui lòng tham khảo original English article bản gốc tiếng Anh bài viết whenever possible. bất cứ khi nào có thể.
Related Articles Bài viết liên quan
- Reset the Root Password of MySQL Server Đặt lại mật khẩu chủ của MySQL Server
- Apple iPhone Root Password and Mobile User Password Apple iPhone Root Password Điện thoại di động của người dùng và mật khẩu
- Reset and Change Windows NT/2000 Administrator or User Password with chntpw in Linux Thiết lập lại và thay đổi Windows NT/2000 Quản trị viên hoặc người dùng Mật khẩu với chntpw trong Linux
- Installing Web Server in FreeBSD 6.0 with Apache 2.2, MySQL 5.0 and PHP 5 – Part 3 Cài đặt Web Server trong FreeBSD 6,0 với 2,2 Apache, MySQL 5.0 và PHP 5 - Phần 3
- Change Oracle Database User Password Cơ sở dữ liệu Oracle thay đổi mật khẩu người dùng
- Change or Set MySQL Long Query Time Value for log-slow-queries Thay đổi hoặc Set MySQL Long Query Time giá trị gia tăng cho log-slow-queries
- Check and Optimize MySQL Database Automatically with Crontab/Cron Kiểm tra và Tối ưu hóa cơ sở dữ liệu MySQL Tự động với Crontab / định kỳ
- How to Reset WordPress Password to Recover Forgotten Secret Làm thế nào để WordPress Đặt lại mật khẩu để Recover quên mật khẩu Secret
- Forgot Windows Administrator Password? Quên mật khẩu quản trị Windows? Ways to Recover and Reset Password in Vista/XP/2003/2K/NT Khôi phục và cách để Đặt lại mật khẩu trong Vista/XP/2003/2K/NT
- Install phpBB 2 in Windows XP running on Apache 2, PHP 5 and MySQL 4 Cài đặt phpBB 2 trong Windows XP chạy trên Apache 2, PHP 5 và MySQL 4










































September 20th, 2009 00:19 20 tháng chín 2009 00:19
I see it worked under Ubuntu for 'trail', but it did not work for me. Tôi nhìn thấy nó làm việc theo Ubuntu cho 'trail', nhưng nó không làm việc cho tôi.
On the contrary: even after following Rajesh's suggestion to use “–skip-grant-tables” instead of “-skip-grant-tables”, even after correcting the erroneous reference to “/etc/rc.d/init.d” for Linux (my Ubuntu has no such directory, it has only “/etc/init.d/”) I get strange error messages by the time I get to step 7. Trên trái: ngay cả sau khi Rajesh gợi ý sau đây để sử dụng "-skip-cấp-bảng" thay vì "-skip-cấp-bàn", ngay cả sau khi điều chỉnh các tham chiếu sai đến "/ etc / rc.d / init.d" cho Linux (Ubuntu của tôi không có thư mục như vậy, nó chỉ có "/ etc / init.d /") tôi nhận được thông báo lỗi kỳ lạ bởi thời gian tôi nhận được đến bước 7.
It seems either one of two things goes wrong. Có vẻ như hoặc là một trong hai điều khi gặp sự cố. Either 1) the server process starts, then soon dies or 2) if it finds the process running at all, it still gives me “ERROR 1045 (28000): Access denies for 'root'@'localhost' (using password: NO)” Hoặc 1) máy chủ bắt đầu quá trình, sau đó sớm chết hoặc 2) nếu nó tìm thấy quá trình hoạt động ở tất cả, nó vẫn mang lại cho tôi "ERROR 1045 (28000): Truy cập chối cho 'root' @ 'localhost' (sử dụng mật khẩu: NO) "
What has my even more baffled is that I get this last message when trying to start and stop mysql! Thậm chí cả những gì đã có vách ngăn của tôi hơn là tôi nhận được tin nhắn này cuối khi cố gắng bắt đầu và ngừng mysql!
Finally, the instructions to edit mysql are highly misleading: one cannot put “–skip-grant-tables” at the END of the line, since the line ends with redirection and '&'. Cuối cùng, các hướng dẫn để sửa mysql rất sai lạc: một không thể đặt "-skip-cấp-bảng" tại END dòng, kể từ dòng kết thúc bằng chuyển hướng và '&'. The line now reads: Hiện dòng lần đọc:
“/usr/bin/mysqld_safe –skip-grant-tables > /dev/null 2>&1 &” "/ Usr / bin / mysqld_safe-skip-cấp bảng> / dev / null 2>-& 1 &"
I am running the very latest released Ubuntu, with all updates as of yesterday. Tôi đang rất phát hành mới nhất của Ubuntu, với tất cả các bản cập nhật như của ngày hôm qua.
August 8th, 2009 10:57 Ngày 08 tháng 8 2009 10:57
[...] This article was written based on information from [...] Bài viết này được viết dựa trên thông tin từ http://www.mydigitallife.info/2006/06/06/change-and-reset-mysql-root-password/ http://www.mydigitallife.info/2006/06/06/change-and-reset-mysql-root-password/ to illustrate changing the mysql password on [...] để minh họa cho việc thay đổi mật khẩu mysql trên [...]
March 12th, 2009 17:35 Ngày 12 tháng 3 năm 2009 17:35
@trail: Worked like a charm, thanks! @ đường mòn: Worked like a charm, thanks!
September 23rd, 2008 17:22 Ngày 23 tháng 9 năm 2008 17:22
worked for me on ubuntu, in just one line: làm việc cho tôi trên Ubuntu, chỉ trong một dòng:
sudo dpkg-reconfigure mysql-server-5.0 sudo dpkg-reconfigure mysql-server-5,0
July 3rd, 2008 05:46 3 tháng 7 năm 2008 05:46
On ubuntu, command is mysqld_safe –-skip-grant-tables & Trên Ubuntu, lệnh là mysqld_safe - skip-grant-tables &
Extra dash is required so mysql can parse it correctly. Dash bổ sung được yêu cầu như vậy mysql có thể phân tích chính xác.
May 5th, 2008 16:52 05 Tháng 5 2008 16:52
[...] judulnya), setelah googling cuma dapat cara untuk mereset dan mengganti password MySQL di UNIX-like di sini. [...] Judulnya), setelah googling cuma dapat cara untuk mereset đánh mengganti mật khẩu MySQL di UNIX như di Sini. Wah, perlu sedikit modifikasi ni … Berikut cara2 yang saya lakukan: 1. Wah, perlu sedikit modifikasi bởi ... kế tiếp của tôi cara2 thấy lakukan: 1. Kill proses MySQL [...] Giết proses MySQL [...]
April 23rd, 2007 08:23 23 Tháng 4 2007 08:23
[...] Change and Reset MySQL root Password » My Digital Life (tags: mysql administration) No Tags Gelesen: 2 / heute: 2 [...] [...] Thay đổi và gốc Đặt lại mật khẩu MySQL »My Digital Life (tags: mysql hành chính) Không có Gelesen Tags: 2 / heute: 2 [...]
December 19th, 2006 14:54 19 Tháng Mười Hai 2006 14:54
[...] Re: Help me retrieve my password Try this link… Change and Reset MySQL root Password [...] Re: giúp tôi lấy lại mật khẩu Hãy thử liên kết này ... Thay đổi và Thiết lập lại mật khẩu root MySQL
July 9th, 2006 12:05 Ngày 09 tháng 7 2006 12:05
I wanna reset my ZXDSL 831 ADSL Modemn Tôi muốn đặt lại ZXDSL của tôi 831 ADSL Modemn
Plz tell me the way how to reset it Plz cho tôi biết cách làm thế nào để đặt lại nó
I need to do that right now Tôi cần phải làm điều đó ngay bây giờ
Best Rgds Best Rgds
dugger(vincitore) dugger (vincitore)
June 6th, 2006 18:18 06 Tháng Sáu Năm 2006 18:18
[...] Alternatively, on any platform, mysql client can be used to set the new password, althought it's less secure way of resetting the password (detailed instruction here): [...] [...] Ngoài ra, trên nền tảng nào, khách hàng mysql có thể được dùng để đặt mật khẩu mới, mặc dù nó kém an toàn hơn cách đặt lại mật khẩu (chỉ dẫn chi tiết tại đây): [...]