Root password reset for MySQL in Linux

Source: Internet
Author: User

Method: After installing MySQL in Linux the default is no password, but for security, we need to set the password, sometimes you can set the password forgotten, then how to do? Then you have to go. Modify a configuration file, it path in /etc/my.cnf, and then cancel the authorization, then do not need to enter the password into MySQL, go to MySQL reset password, after the change to remember to delete in /etc/my.cnf Cancels the authorization statement.

Description: The following MySQL command I have set its environment variables, if not set then you have to use its absolute path to execute this command.

(1) Set password

#mysqladmin-uroot password ' 123456 '

Explanation: The default password is not, the initial set of passwords, where 123456 is the password I set

After setting up, you want to log in and enter the password you just set.

#mysql-uroot-p123456-p is behind you. The password you set in the previous step


(2) What if you forget the password? Then go to edit the configuration file, add red information to cancel authorization

#vim/etc/my.cnf
Skip-grant

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/7F/52/wKiom1cZyTnTBusYAAAzsXrlh-o097.png "title=" QQ picture 20160422144725.png "alt=" Wkiom1czytntbusyaaazsxrlh-o097.png "/>

# /etc/init.d/mysqld Restart Restart service

#mysql into MySQL, because just the operation, now do not enter any password to go into MySQL

>use MySQL Usage library
>update User Set Password=password (' 12345678 ') where user= ' root '; Change the password, add a new password inside the parentheses
>quit quit MySQL

Remember to configure the file next, delete the line just
#vim/etc/my.cnf
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/7F/52/wKiom1cZylqAqn7wAAAdatzgPqg981.png "title=" Ww20160422145254.png "alt=" Wkiom1czylqaqn7waaadatzgpqg981.png "/>

#/etc/init.d/mysqld Restart Restart Service
#mysql-uroot-p12345678 (12345678 for the password modified above) so you can re-login to MySQL.



This article is from the "11165660" blog, please be sure to keep this source http://11175660.blog.51cto.com/11165660/1766710

Root password reset for MySQL in Linux

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.