Home > Database > Mysql Tutorial > How to reset root password in mysql

How to reset root password in mysql

angryTom
Release: 2020-02-29 11:20:06
Original
9192 people have browsed it

How to reset root password in mysql

mysqlHow to reset root password

1. Close the MySQL server:

service mysql stop
Copy after login

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 &
Copy after login

Note:

Maybe your system does not have the safe_mysqld program (Windows or Ubuntu operation System), you can use mysqld:

mysqld --skip-grant-tables &
Copy after login

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
Copy after login

4. Start MySQL:

service mysql start
Copy after login

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 新密码
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template