How can I change the password when I forget the password of MySQL?

Source: Internet
Author: User
The password of the root account of MySQL is empty by default. It is often forgotten after the password is changed. If you forget the password of the root account, how can you change the password? Here is a feasible method to solve this problem by changing the password in MySQL security mode (skipping the permission check. This document introduces MySQ in Windows and Linux respectively.

The password of the root account of MySQL is empty by default. It is often forgotten after the password is changed. If you forget the password of the root account, how can you change the password? Here is a feasible method to solve this problem by changing the password in MySQL security mode (skipping the permission check. This document introduces MySQ in Windows and Linux respectively.

The password of the root account of MySQL is empty by default. It is often forgotten after the password is changed. If you forget the password of the root account, how can you change the password? Here is a feasible method to solve this problem by changing the password in MySQL security mode (skipping the permission check. This article introduces how to change the password when MySQL forgets the password in Windows and Linux respectively, hoping to help beginners solve the headache of losing the password.

Reset the password of MySQL in Windows

MySQL is usually installed as a Windows service.

1. Start the cmd command window:

# Disable MySQL service D: \ MySQL \ bin> SC stop mysql # Start MySQLD: \ MySQL \ bin> mysqld -- skip-grant-tables in Safe Mode

2. Do not close it. Start a new cmd command window:

# Log on to the MySQL database D: \ MySQL \ bin> mysql-u root-pmysql> use mysql; mysql> update user set password = password ("123456 ") where user = "root"; mysql> flush privileges;

3. Close the preceding two windows and start the MySQL service.

# Start MySQL service C: \> SC start mysql

Reset the password of MySQL in Linux

In Linux, password resetting is similar to in Windows.

# Stop the MySQL service [root @ www ~] #/Etc/init. d/mysql stop # Start MySQL in safe mode [root @ www ~] #/Usr/local/mysql/bin/mysqld_safe -- skip-grant-tables &
# Log on to MySQL [root @ www ~] # Mysql-u root-pmysql> use mysql; mysql> update user set password = password ("123456") where user = "root"; mysql> flush privileges;
# Start the MySQL service [root @ www ~] #/Etc/init. d/mysql start

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.