MySQL database forgot root password resolved

Source: Internet
Author: User

2018.6.1

MySQL database forgot root password resolved:

  • Enter configuration file/etc/my.cnf
  • Add a statement under [mysqld]: Skip-grant-tables
  • Restart Mysqld:service mysqld Restart
  • Login MySQL database without password: mysql-uroot-p
  • Operation after entering the database:

    Using the MySQL Library

    mysql> use MySQL;
    Reading table information for completion of table and column names
    Can turn off this feature to get a quicker startup with-a
    Database changed

    Be sure to check the User password field name clearly

    Mysql> SELECT * from user limit 1\g;
    1. Row *********************
    Host:localhost
    User:root
    Select_priv:y
    ... (Omitted here)
    Plugin:mysql_native_password
    Auther_string: *81f5e21e35407d884a6cd4a731aebfb7af209e1b
    # This string of characters is the encrypted password, select its field name
    Password_expired:n
    Password_last_changed:2018-05-31 15:12:34
    Password_lifetime:null
    Account_locked:n
    1 row in Set (0.00 sec)

  • Change Password:

    mysql> Update user set Auther_string=password (' 123 ') where user= ' root ';
    Query OK, 1 row affected, 1 Warning (0.00 sec)
    Rows matched:2 changed:1 warnings:1

  • Log out of the database after successful modification, comment out the password-free login in the configuration file
  • Restart mysqld: [[email protected] ~]# systemctl Restart Mysqld
  • Verification: [[email protected] ~]# mysql-uroot-p123

MySQL database forgot root password resolved

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.