MySQL Modify and hack login password (details)

Source: Internet
Author: User

MySQL modify or crack login password

First, reset the MySQL admin password

Skip the Authorization form to start the MySQL service program

This step mainly utilizes Mysqld's--skip-grant-tables option, which can be selected in different ways, but essentially the same. The following are available in three ways, either one of which can be selected.

Mode 1 (recommended), execute MySQL script from service, add--skip-grant-tables parameter at the end:

[[email protected] ~]# service mysql stop   service off [[email protected]  ~]# service mysql start --skip-grant-tablesStartingMySQL............                       [OK][[email protected] ~]# service mysql statusmysql running  (45640)          [Determine][[email protected] ~]# mysql -u  rootmysql>  update mysql.user set password=password ("123456")       ->  where user= "root"  and host= "localhost"; mysql>   flush privileges; mysql>  exit  re-login with new password 123456 

Mode 2, execute the MYSQLD_SAFE process, add the--skip-grant-tables parameter:

[[email protected] ~]# service mysql restart   service must be turned on [[email protected ] ~]# mysqld_safe --user=mysql --skip-grant-tables &[1] 46076160930  13:23:51 mysqld_safe logging to  '/var/lib/mysql/www.ceshi1.com.err '. 160930 13:23:51  mysqld_safe a mysqld process already exists input:mysql   Enter to enter the database MySQL >  update mysql.user set password=password ("123456")       ->  where user= "root"  and host= "localhost"; mysql>  flush  privileges; mysql>  exit  using the new password 123456 to log back in 

Mode 3, modify the MY.CNF configuration, add Skip_grant_tables=1 startup settings:

[Email protected] ~]# Vim/etc/my.cnf[mysqld]skip_grant_tables=1. .. [[Email protected] ~]# service MySQL restart[[email protected] ~]# mysql-u rootmysql> update mysql.user set password= Password ("123456"), where user= "root" and host= "localhost"; mysql> flush Privileges; mysql> exit use new password 123456 re-login Note: After normal login vim/etc/my.cnf comment out or delete skip_grant_tables=1 restart service

In order to avoid conflicts, the above three methods should not be used simultaneously. To test the different ways separately, you should also deactivate the MySQL service program (direct service MySQL stop) that was started by other means first.


By executing the "FLUSH privileges;" Allows the authorization table to take effect immediately, for the normal running MySQL service, you can also use the above method to modify the password, do not restart the service. In this case, because it is a recovery password, it is best to restart the MySQL service program, so the above "FLUSH privileges;" The action can be skipped.



Second, the normal setup MySQL management password

The normal premise is that the current MySQL Admin user (root) password is known.

1) Method 1, set under shell command line

Using the Mysqladmin management tool, you need to verify the old password. For example, the following operation will set the root password to 1234567:

[[email protected] ~]# mysqladmin-u root-p password ' 1234567 ' Enter password://Verify the original password

2) Method 2, using the Set password command after logging in to mysql> as root

This is the same way as when you first change the password after the new installation mysql-server, you can usually use:

mysql> SET PASSWORD for [email Protected]=password (' 1234567 '); Query OK, 0 rows affected (0.16 sec)

3) Method 3, use the grant authorization tool to set the mysql> after logging in as root

This is the most common way of user authorization (the next section will do more licensing exercises):

Mysql> GRANT All on * * to [e-mail protected] identified by ' 1234567 '; Query OK, 0 rows Affected (0.00 sec)

4) Method 4, use Update to update the corresponding table record after log in as root mysql>

This method is the same as when recovering a password:

mysql> update mysql.user set password=password (' 1234567 ')-> WHERE user= ' Root '  and host= ' localhost ';    //reset the root password query ok, 0 rows  affected  (0.17 sec) rows matched: 1  changed: 0  warnings:  0mysql> flush privileges;                       //Refresh Authorization Form query ok, 0 rows  affected  (0.00 sec) 

In the above method, it is important to note that when the MySQL service is started with the--skip-grant-tables option, the "FLUSH privileges" is not executed; Operation, it is not possible to set the password through set password or grant mode. For example, when validating both of these approaches, you will see error 1290 errors:

mysql> SET PASSWORD for [email Protected]=password (' 1234567 '); ERROR 1290 (HY000): The MySQL server is running with the--skip-grant-tables option so it cannot execute this Statementmys Ql> GRANT All on * * to [e-mail protected] identified by ' 1234567 '; ERROR 1290 (HY000): The MySQL server is running with the--skip-grant-tables


This article is from the "Kingson" blog, make sure to keep this source http://81703069.blog.51cto.com/5524831/1858092

MySQL Modify and hack login password (details)

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.