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