How does one forget the root user password for MySQL in Linux?

Source: Internet
Author: User

1. You forget the root user password of your system. I forgot the root user solution in Linux to solve this problem first.) log on to the system and enter the terminal.

[Root @ localhost/] #

Ii. Killing the MySQL process

Method 1: [root @ localhost/] # killall mysqld

Method 2: [root @ localhost/] # ps-Aux // view all processes and find the MySQL process PID

Then

[Root @ localhost/] # kill PID // PID indicates the MySQL process ID

3. Use the -- skip-grant-tables parameter to start mysqld

[Root @ localhost/] #/usr/local/MySQL/bin/mysqld_safe -- skip-grant-tables &

// Where/usr.../bin is my MySQL installation directory

[Root @ localhost/] #/usr/local/MySQL/bin/MySQL // enter MySQL

Mysql> use MySQL // switch to MySQL database

Mysql> Update user SET Password = PASSWORD ('000000') where user = 'root ';

// Set the root password to 123456.

Iv. Notes

The full command to load MySQL like this is:

Mysqld_safe -- skip-grant-tables -- autoclose

(Editor's note: Our Technical Reviewer found that he had to launch the mysqld_safe command

Without the '-- autoclose' flag, otherwise the daemon never started .)

This is what foreign websites have said. I have succeeded in using autoclosa.

However, the following error message is displayed when I run/usr/local/MySQL/bin/mysqld_safe -- skip-grant-tables:

./Mysqld_safe

Starting mysqld daemon with databases from/usr/local/var

Stopping server from PID file/usr/local/var/localhost. localdomain. PID

Mysqld ended

Then enter/usr/local/var/

Vi./localhost. localdomain. Err contains the following content:

050410 04:02:59 mysqld started

050410 4:03:00 InnoDB: operating system error number 13 in a file operation.

InnoDB: the error means mysqld does not have the access rights

InnoDB: the directory.

InnoDB: file name./ibdata1

InnoDB: File Operation call: 'create '.

InnoDB: cannot continue operation.

050410 04:03:00 mysqld ended

If the access permission of the./var directory is suspected, perform the following operations:

Chmod 777./var

Then re-execute the background, and the above error still exists, but the error message in the localhost. localdomain. Err file is changed to not found

Help. * file (I cannot remember this file name)

This is because the read and write permissions of my MySQL installation directory are as follows:

The MySQL installation directory belongs to the user root, but the group is MySQL

Change the group to root.

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.