Several ways MySQL resets the root password (windows+linux)

Source: Internet
Author: User

How to reset the root password:

Under Windows system:
1, stop the MySQL service;
2, the new file Init-root.txt, write the following content:
Update mysql.user Set password = password (' newpwd ') where user = ' root ';
Flush privileges;
Save
3. Open the command line and enter: C:\mysql\bin\mysqld--init-file=c:\\mysql-init.txt
The--init-file option points to the initialized file

If MySQL is installed through the GUI Interface Installation Wizard, the following:
C:\> "C:\Program files\mysql\mysql Server 5.6\bin\mysqld.exe"
--defaults-file= "C:\\Program Files\\mysql\\mysql Server 5.6\\my.ini"
--init-file=c:\\mysql-init.txt
--defaults-file options point to MySQL configuration file

4, after the service restart password has been reset, you can delete the Init-root.txt file.


Linux, the first method is similar to Windows:
1, stop the MySQL service (kill process);
2, the new file Init-root, write the following content:
Update mysql.user Set password = password (' newpwd ') where user = ' root ';
Flush privileges;
Save
3. Running in the shell: Mysqld_safe--init-file=/home/me/mysql-init &

4, the service restarts, you can delete the Init-root.txt file.

Methods available on all platforms:
1, Stop mysqld service,
2, configuration my.conf file, join:--skip-grant-tables option, skip permission check;--skip-networking option to block remote client network connection;
3, restart the MYSQLD service,
Shell> Service mysqld Start
4, Login client,
shell> MySQL
5. Change Password:
mysql> Update mysql.user Set password = password (' newpwd ') where user= ' root ';
mysql> flush Privileges;
6. Close Mysqld Service, remove--skip-grant-tables and--skip-networking options, restart service

Reference:

MySQL Official documentation:
Http://dev.mysql.com/doc/refman/5.6/en/resetting-permissions.html

Several ways MySQL resets the root password (windows+linux)

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.