mysqlHow to reset root password
1. Close the MySQL server:
service mysql stop
2. Enter the directory for security Mode to start MySQL
Recommended learning: "mysql introductory video"
cd /usr/local/mysql/bin ./mysqld_safe --skip-grant-tables &
Note:
Maybe your system does not have the safe_mysqld program (Windows or Ubuntu operation System), you can use mysqld:
mysqld --skip-grant-tables &
3. After startup, the root user logs in to mysql with an empty password:
# mysql -u rootmysql> update mysql.user set password=PASSWORD('123456') where User='root'; # 修改密码 mysql> flush privileges; # 刷新权限 mysql> quit
4. Start MySQL:
service mysql start
This is it Logged in with new password 123456.
If you know the password, you can use the following command:
# mysqladmin -u root -p password 新密码
Related recommendations:
How to change the password in mysql?
The above is the detailed content of How to reset root password in mysql. For more information, please follow other related articles on the PHP Chinese website!