Reset password mysql
Databases rất quan trong với hầu hết ứng dụng cũng như hệ thống. Việc mất password vì bất kỳ lý do gì hoặc quên password databases thì cực kỳ nguy hiểm. Vậy làm thế hào Reset password mysql: Để Reset password mysql chúng ta thực hiện các bước như sau:
Bước 1: Stop MySQL Service
The first thing to do is stop MySQL. If you are using Ubuntu or Debian the command is as follows:
/etc/init.d/mysql stop
For CentOS, Fedora, and RHEL the command is:
/etc/init.d/mysqld stop
Bước 2: Safe mode Mysql
Next we need to start MySQL in safe mode – that is to say, we will start MySQL but skip the user privileges table. Again, note that you will need to have sudo access for these commands so you don’t need to worry about any user being able to reset the MySQL root password:
sudo mysqld_safe --skip-grant-tables &
Note: The ampersand (&) at the end of the command is required.
Bước 2: Login vào Mysql
All we need to do now is to log into MySQL and set the password.
mysql -uroot
Note: No password is required at this stage as when we started MySQL we skipped the user privileges table.
Next, instruct MySQL which database to use:
use mysql;
Bước 4: Reset Password
Enter the new password for the root user as follows:
update user set password=PASSWORD("mynewpassword") where User='root';
and finally, flush the privileges:
flush privileges;
Bước 5: Restart Mysql
Now the password has been reset, we need to restart MySQL by logging out:
quit
/etc/init.d/mysqld restart
Như vậy là chúng ta đã reset thành công password mysql. Các bạn thấy có dễ không? rất dễ phải không nào. Bạn nào không làm được, gọi ngay cho mình, mình hướng dẫn cho các bạn luôn và ngay.
