How to handle forgotten mysql passwords (linux and windows)

Source: Internet
Author: User
Tags mysql tutorial

How to handle forgetting the mysql password (linux, windows) This section describes how to handle the mysql password. It mainly describes how to retrieve the password in different operating systems, such as linux and windows.

How to deal with password in the forgot mysql tutorial (linux, windows)
This section describes how to handle mysql passwords. It mainly describes how to retrieve passwords in different operating systems, such as linux and windows.

#/Etc/init. d/mysql stop
# Mysqld_safe -- user = mysql -- skip-grant-tables -- skip-networking &
# Mysql-u root mysql
Mysql> update user set password = password ('newpassword') where user = 'root ';
Mysql> flush privileges;
Mysql> quit
#/Etc/init. d/mysql restart
# Mysql-uroot-p
Enter password: <enter the new password newpassword>
Mysql>

How to deal with windows forgot mysql password

1. Edit the MySQL configuration file:

In windows: % MySQL_installdir % my. ini // In the MySQL installation directory, my. ini is the configuration file of MySQL.

In linux:/etc/my. cnf

Add the following line in the [MySQLd] configuration section:
Skip-grant-tables

Save and exit editing.

2. Restart the MySQL service.

In windows:
Net stop MySQL
Net start MySQL

In linux:
/Etc/init. d/MySQLd restart

3. Set a new ROOT password.

Then run the following command in the command line:
MySQL-uroot-p
Press enter without a password to go to the database tutorial.

Go to the MYSQL table
Use mysql;

Run the following statement to update the root password to 123456:
Update user set password = PASSWORD ("123456") where user = 'root ';

Quit exit MySQL

4. Restore the configuration file and restart the service.
Then, modify the MySQL configuration file and delete the row that you just added.
Restart the MySQL service again. The password has been changed.

Related Article

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.