Solution for Windows/LinuxMySQL to forget the root password

Source: Internet
Author: User
The root User Password of MySQL is often easy to forget. It has a mechanism to handle permission errors by skipping the permission check and starting. This document compares Windows and Linu

The root User Password of MySQL is often easy to forget. It has a mechanism to handle permission errors by skipping the permission check and starting. This document compares Windows and Linu

The root User Password of MySQL is often easy to forget. It has a mechanism to handle permission errors by skipping the permission check and starting. This article introduces how to forget or reset a MySQL password in Windows and Linux respectively, hoping to help beginners solve the headache of losing a password.

Reset Password for MySQL for Windows

In general, MySQL in Windows is installed as a service. This document takes Windows 2003 as an example.

1. Stop the MySQL service in the control panel-Administrative Tools-service.

2. Start the MySQL service in security mode (without permission authentication)

"Start Menu"-"run"-Enter "cmd" and press ENTER-cd to the bin directory under the MySQL installation directory, and then execute:

1mysqld-nt.exe -- skip-grant-tables

3. MySQL is running normally. log on to MySQL through PhpMyAdmin. The username is root and the password is empty or contains any other characters;

Reset Password for MySQL for Linux

The principle of password reset in Linux is similar to that in Windows. It uses security mode to skip the permission check and start MySQL.

1. Stop the MySQL service and run the following command:

1 [root @ www ~] #/Etc/init. d/mysql stop

2. Start MySQL in safe mode:

1 [root @ www ~] #/Usr/local/mysql/bin/mysqld_safe -- skip-grant-tables &

3. You can change the password through phpMyAdmin or the command line. The username is root and the password is empty.

Command for password modification:

First, log on to MySQL in command line mode:

1 [root @ www ~] # Mysql-u root-p

Run the following three commands:

> Use mysql;
> Update user set password = password ("new password") where user = "root ";
> Flush privileges;

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.