MySQL forgot password processing process

Source: Internet
Author: User

Recently the project has used MySQL, the project has no OPS, the project manager told me to use Linux under the basic environment, which encountered a variety of pits, now record, convenient for later.

The following content is from the online excerpt, if there is infringement, please contact me to delete.

1.mysql5.7 generates an initial password, and the previous version does not need to be logged on for the first login.
Shell> Find/-name. Mysql_secret
Shell> Vim/var/log/mysqld.log
/password find a temporary generated password

2. If the first step succeeds, use this password to continue with the 7th step
3. Modify the MySQL configuration file (default is/ETC/MY.CNF) and add a line under [Mysqld] Skip-grant-tables
A. Close the running MySQL service.
B. Vim/etc/my.ini last line Add skip-grant-tables//start MySQL service and Skip permission table authentication.
4.service mysqld Restart, you can enter it directly with MySQL

5. mysql> Update Mysql.user set Authentication_string=password (' 123456 ') where user= ' root ' and Host = ' localhost ';

It's best to check the fields in the user table about the password before using the statement. Depending on the version, there are some authentication_string, some password

mysql> flush Privileges;
Mysql> quit;
6. Restore the/etc/my.cnf file and restart Mysql:service mysql Restart, this time you can use Mysql-u root-p ' 123456 ' to enter the

7.mysql>set PASSWORD = PASSWORD (' newpasswd '); Set new password//newpasswd is the new password

PS: Error: 1130-host. Is the workaround for the MYSQL server when allowed to connect
It may be that your account is not allowed to log on remotely, only on localhost. This time, as long as the computer on the localhost,
After logging in to MySQL, change the "host" entry in the "User" table in the "MySQL" Database and rename "%" from "localhost"
Mysql-u root-p
Mysql>use MySQL;
Mysql>update User Set host = '% ' where user = ' root ' and host = ' localhost ';
Mysql>select host, user from user;

Mysql>flush privileges;

Shell>service mysqld Restart;

MySQL forgot password processing process

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.