How to change the password when the mysql password is forgotten (Linux & amp; Windows)

Source: Internet
Author: User

I. Linux Article 1. stop mysql service: service mysql stop; 2. Modify the my. cnf file and find/-name my. cnf. The file contains
[Mysqld] datadir =/var/lib/mysqlsocket =/var/lib/mysql. sockuser = mysql
This is the file we are looking for. Add skip-grant-tables under user-mysql, save the file, and exit 3, mysqld restart; 4, service mysql start.5. Enter mysql to enter mysql! Ii. Windows 1. First, stop the running MySQL process> net stop mysql. If it is not loaded as a service, you can directly close it in the Process Manager or service. 2. Start MySQL in safe mode to enter the mysql directory and run it under the command line> d:> cd xampp/mysql/bin> mysqld.exe -- after the skip-grant-tables3, you can enter MySQL without a password> mysql-u root-p prompt to enter the password directly press Enter. 4. Change Password> use mysql> update user set password = Password ('new password') where User = 'root';> flush privileges; 5. Start MySQL and close all MySQL processes in Task Manager. Run the following command to start MySQL.> Net start mysqlmysqladmin-u root-p shutdown

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.