MySQL root user root password after forgetting the processing method

Source: Internet
Author: User
Tags mysql in mysql database

Steps under the Windows platform

1. Log on to the Windows system as an administrator

2. Use Windows Service Management tool or task Manager to stop MySQL service

3. Create a single line of text files, save as C:mysqlpwdhf.txt,

Content is set PASSWORD for ' root ' @ ' localhost ' = PASSWORD (' Mynewpassword ');

4. Open a console window and get a DOS command prompt

5. Suppose your MySQL home directory is c:/mysql/bin,

Then run C:mysqlbinmysqld-nt--init-file=c:mysqlpwdhf.txt,

If the MySQL database server is installed with the Installation Wizard, it needs to be changed through the Service Management tool.

You need to find and add the default settings file.

Then run mysqld-nt--defaults-file= "Pathmy.ini"--init-file=c:mysqlpwdhf.txt

6. Stop the MySQL database service and then restart MySQL in normal mode

7. You can log on to the server normally.

Steps in a UNIX environment

1. Log on to the system as root or as a user who initiates the mysqld process

2. Locate and locate the file that contains the MySQL service process number. PID, the file generally may

In/var/lib/mysql/,/var/run/mysqld/,/usr/local/mysql/data/,

The file name is generally the "machine name. pid" format. Using commands under the shell

Kill ' Cat/mysql-data-directory//host-name.pid ' to end the MySQL service process

3. Create a single-line text file that can be arbitrarily named, assuming it is mysql-init,

Saved in the user's home directory ~ can be,

The contents of the file are set PASSWORD for ' root ' @ ' localhost ' = PASSWORD (' Mynewpassword ');

4. Restart MySQL with option, specific command for Mysqld_safe--init-file=~/mysql-init

Mysql-init files should be deleted after normal

5. You can connect to the database with a new password.

A common solution:

-Use the Client interaction tool MySQL to set up the following steps:

1. Stop MySQL service and re---skip-grand-table--user=root

Option to start the MySQL service (you can omit the--user=root option under Windows)

2. Using the client-side Interactive tool MySQL connection server, Shell>mysql-u root

3. Execute the following statement in the client-side interactive tool MySQL:

mysql> UPDATE mysql.user SET password=password (' newpwd ')

-> WHERE user= ' root ';

mysql> FLUSH privileges;

4. You can use NEWPWD as a password to log on to the server.

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.