Reset the root password for mysql and set the root password for mysql.

Source: Internet
Author: User

Reset the root password for mysql and set the root password for mysql.

Recently, mysql was used in another project. Since mysql was installed a long time ago, the root password was forgotten.

Windows:

1. log in as a system administrator;

2. Stop the MySQL service;

3. Go to CMD and enter the MySQL installation directory, for example, D:/MySQL Server 5.0 /;

4. Skip the permission check and start MySQL,

D:/MySQL Server 5.0/bin/mysqld-nt -- skip-grant-tables

5. Open a new CMD and enter D:/MySQL Server 5.0/bin /,

Reset the root password

D:/MySQL Server 5.0/bin/mysqladmin-uroot flush-privileges password "newpassword"

D:/MySQL Server 5.0/bin/mysqladmin-u root-p shutdown

Replace newpassword with your new password. The second command will allow you to repeat the new password.

6. net start mysql in cmd

Unix & Linux:

1. log on to the system using root or a user running mysqld;

2. Use the kill command to end the mysqld process;

3. Use the-skip-grant-tables parameter to start MySQL Server

# Mysqld_safe-skip-grant-tables &

4. Then use the empty password to log on to MySQL as the root user; mysql-u root

5. Set a new password for root @ localhost

Mysql> update mysql. user set password = PASSWORD ('new password') where User = 'root' mysql> flush privileges; mysql> quit

6. Restart MySQL

Note that the two marked in red are "-". If the name is not executed, an error is returned. "-k ......"

 

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.