After installing mysql5.7 on centos7, an error 1045 (28000) is reported: access denied for user ‘root’ @’localhost ‘(using PAS)

After installing mysql, there will be a temporary password to check the log, but it still doesn’t work after checking the login modification secret
ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password:yes)
so
1. Stop mysql service

systemctl stop mysqld.service

2, modify the profile to log in without password

[HTML] view plain copy

    1. vi/etc/my CNF </ ol>

Add it at the end

[HTML] view plain copy

      1. skip – grant – tables </ ol>
      1. save

3. Start mysql

[HTML] view plain copy

        1. systemctl start mysqld. Service </ ol>
        1. 4, log in musql

[HTML] view plain copy

          1. mysql -u root </ ol>
          1. Be careful not to add minus p here

5, modify the password, mySQL5.7 use this syntax

[HTML] view plain copy
The

            1. use mysql; </ ol>

[HTML] view plain copy

              1. update mysql.user set authentication_string=password(‘123456′) where user=’root’; </ ol>
              1. 6, go back to the second step remove the plus

[HTML] view plain copy

                1. skip – grant – tables </ ol>
                1. Save and restart mysql

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
In fact, after installing mysql by default or in the log to generate a default password /var/log/mysqld.log
Login to mysql to reset the default password

[HTML] view plain copy

                  1. set password = password (‘ you password “); </ ol>

If the password level does not match the default level requirement, it will be reported

[HTML] view plain copy

                    1. Your password does not satisfy the current policy requirements

You need to change the level and the minimum default password number

[HTML] view plain copy
The

                    1. set global validate_password_policy = 0; The set global validate_password_length = 4; </ ol>
                    1. And then just set the password

# # # # # # # # # # # # # # # # # # #
Error 1130 on remote connection

[HTML] view plain copy

                    1. mysql; The use of mysql; Mysql; Select ‘host’ from user where user=’root’; Mysql; Update user set host =’ %’ where user =’root’; Mysql; Flush privileges; Mysql; Select ‘host’ from user where user=’root’; </ ol>

Read More: