MySQL 5.7 Setting the root password method

Source: Internet
Author: User

  • Operating system:
    [Email protected] ~]#  cat/etc/redhat-release CentOS Linux release 7.1.1503
  • MySQL version 5.7.9
    Mysql> Select version ()    , +-----------+| version () |+-----------+| 5.7.9     |+-----------+1 row in Set ( 0.00 sec)
  • Install the Yum repo source for MySQL:
    RPM-IVH http://repo.mysql.com//mysql57-community-release-el7-7.noarch.rpm
  • Install MySQL
    Yum Install Mysql-community-serveryum Install Mysql-community-client
  • Modify MySQL configuration file skip password verification
    [Mysqld]skip-grant-tablesskip-networking
  • Start MySQL:
    Systemctl Start mysqld
  • Anonymous login MySQL set root password:
    [[email protected] ~]# mysqlwelcome to the MySQL Monitor. Commands End With; or \g.your MySQL connection ID is 2Server version:5.7.9 mysql Community Server (GPL) Copyright (c), Oracle and/ or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names trademarks of their respectiveowners. Type ' help ', ' or ' \h ' for help.  Type ' \c ' to clear the current input statement.mysql> update mysql.user set Password=password (' Test ') where user= ' root ' and host= ' localhost '; ERROR 1054 (42S22): Unknown column ' PASSWORD ' in ' Field List ' mysql> ALTER USER ' root ' @ ' localhost ' identified by ' test ' ; ERROR 1131 (42000): You is using MySQL as an anonymous user and anonymous users is not allowed to change passwordsmysql& Gt Update Mysql.user Set Authentication_string=password (' Test ') where user= ' root ' and host= ' localhost '; Query OK, 1 row affected, 1 warning (0.07 sec) Rows matched:1 changed:1 warnings:1mysql> FLUsh privileges; Query OK, 0 rows affected (0.06 sec) mysql> exit; Bye
  • To cancel the password-skipping authentication:
    [Mysqld] #skip-grant-tables#skip-networking
  • To restart MySQL:
    Systemctl Restart Mysqld
  • You must reset the password by using the ALTER User:
    mysql> show databases; ERROR 1820 (HY000): Must reset your password using ALTER USER statement before executing this statement.
  • Reset Password:
    Mysql> ALTER USER ' root ' @ ' localhost ' identified by ' ******** '
  • The password requires complexity requirements:
    mysql> SHOW VARIABLES like ' validate_password% '; +--------------------------------------+--------+| Variable_name                        | Value  |+--------------------------------------+--------+| validate_password_dictionary_file    |        | | Validate_password_length             | 8      | | validate_password_mixed_case_count   | 1      | | validate_password_number _count       | 1      | | validate_password_policy             | MEDIUM | | Validate_password_special_char_count | 1      |+--------------------------------------+--------+6 rows in Set (0.00 sec)




MySQL 5.7 Setting the root password method

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.