(--1--) forgot MySQL password processing method in Linux environment

Source: Internet
Author: User
Tags administrator password

Overview:

In the production environment, for the MySQL database service I need to control and password control, the main prevention of arbitrary host, any user malicious login operation, but sometimes we do these security policy work, there will be forgotten password, or password is malicious modification, now said the situation is likely to occur, What should I do with you when these anomalies arise? Here's how MySQL password is initialized:


MySQL Password initialization recovery method (1)-- Skip the Authorization table login method via the MY.CNF configuration file

1. Stop MySQL service (recommended to stop MySQL service first)

# Service Mysqld Stop

2. Modify the MY.CNF configuration file to add "skip-grant-tables" option

# Vim/etc/mysql/my.cnf[mysqld]skip-grant-tables

3. Start the MySQL service

# service Mysqld Start

4. Log in to MySQL to change the root password

MySQL > Use mysql;mysql > UPDATE user SET Password = Password (' gzsamlee-mysql ') WHERE user = ' root '; MySQL > FLUSH privileges;

5. Delete or comment the "skip-grant-tables" option in the MY.CNF configuration file

# Vim/etc/mysql/my.cnf[mysqld] #skip-grant-tables

6. Restart the MySQL service to take effect on the new password

# Service Mysqld Restart


MySQL Password initialization recovery method (2)-- Skip the Authorization table login method by starting the service

1. Stop the MySQL service

# Service Mysqld Stop

2. Modify the configuration file to add--skip-grant-tables--skip-networking

# vim/etc/init.d/mysqld $bindir/mysqld_safe--skip-grant-tables--skip-networking--datadir= "$datadir"--pid-file= "$ Mysqld_pid_file_path "$other _args >/dev/null 2>&1 & wait_for_pid created" $! " "$mysqld _pid_file_path"; Return_value=$?

3. Start the MySQL service

# service Mysqld Start

4. Modify the Administrator password

MySQL > Use mysql;mysql > UPDATE user SET Password = Password (' gzsamlee-mysql ') WHERE user = ' root '; MySQL > FLUSH privileges;

5. Stop the MySQL service

# Service Mysqld Stop

6. Modify the configuration file remove--skip-grant-tables--skip-networking

# vim/etc/init.d/mysqld $bindir/mysqld_safe--datadir= "$datadir"--pid-file= "$mysqld _pid_file_path" $other _args > /dev/null 2>&1 &wait_for_pid created "$!" "$mysqld _pid_file_path"; Return_value=$?

7. Start the MySQL service

# service Mysqld Start


This article is from the "Opensamlee" blog, make sure to keep this source http://gzsamlee.blog.51cto.com/9976612/1792941

(--1--) forgot MySQL password processing method in Linux environment

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.