How to change password when MySQL password is forgotten (linux&windows)

Source: Internet
Author: User

One, Linux 1, stop MySQL services: service MySQL stop;2, modify my.cnf file, can be found through the Find/-name my.cnf file, the content contains
[Mysqld]datadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.sockuser=mysql
That is the file we are looking for, added under User-mysql: Skip-grant-tables, save and exit 3,mysqld restart;4,service mysql start.5, enter MySQL to enter mysql! Second, Windows 1, first stop the running MySQL process >net stop MySQL is not loaded as a service and can be shut down directly in the Process Manager or service. 2. Start MySQL in Safe mode to enter the MySQL directory run >D:>CD xampp/mysql/bin >mysqld.exe--skip-grant-tables3 on the command line. After completion, you can use the password to enter the MySQL >mysql-u root-p prompt to enter the password when the direct carriage. 4. Change Password >use mysql>update user set Password=password (' New password ') where user= ' root '; >flush privileges;5, Start the MySQL service to close all MySQL processes in Task Manager and start with the following command. >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.