Root password reset for MySQL

Source: Internet
Author: User

MySQL How to set the password, the default is no password


Mysqladmin-uroot password ' lizheng123 '


Password required to use Mysql-uroot login prompt



Mysql-uroot-plizheng123 will be able to log in normally



What if the root password of MySQL is forgotten?


1. Need to initialize the password, first open the configuration file


Vi/etc/my.cnf


Add a parameter below the MYSQLD


650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M02/8B/26/wKiom1hFkkvTjpl2AACq4yBdkkY940.png-wh_500x0-wm_3 -wmp_4-s_522665520.png "title=" Rw.png "alt=" Wkiom1hfkkvtjpl2aacq4ybdkky940.png-wh_50 "/>


2. Restart MySQL


3. Login with MySQL to log in normally



4. Use MySQL table and update


Use MySQL



Update user set Password=password (' lizheng123 ') where user= ' root ';



5. View


SELECT * from user where user= ' root ' \g;



6. Open the configuration file to comment out the parameters just added, in the login database to find the need to enter a password


Vi/etc/my.cnf


650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M01/8B/23/wKioL1hFknywgcHlAACtVh4fsp4161.png-wh_500x0-wm_3 -wmp_4-s_2031175140.png "title=" Gg.png "alt=" Wkiol1hfknywgchlaactvh4fsp4161.png-wh_50 "/>

Restart


/etc/init.d/mysql restart


Direct input MySQL will error



Enter user name and password to log in normally


Mysql-uroot-plizheng123


Root password reset for MySQL

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.