[[email protected] ~]# mysqladmin-uroot password ' 123456 ' set a password for MySQL
[[email protected] ~]# mysqladmin-uroot password ' 123456 ' local login MySQL
If we now have the MySQL password forgotten, reset it now.
[[email protected] ~]# vim/etc/my.cnf Edit configuration file
Skip-grant Join this Save to exit (do not authorize direct login)
[[email protected] ~]#/etc/init.d/mysqld restart reboot mysqlshutting down MySQL ..... success! Starting MySQL. success!
[[email protected] ~]# Mysql-uroot can log in Welcome to the MySQL Monitor directly. Commands End With; or \g.your MySQL connection ID is 1
mysql> use MySQL//using MySQL library mysql> update user set Password=password (' 654321 ') where user = ' root '; Update table (change password) mysql>quit
then find the/etc/my.cnf configuration file, delete the previous skip-grant command, Restart MySQL service after saving exit
[[email protected] ~]# /etc/init.d/mysqld restart
[[email protected] ~]# mysql-uroot-p654321 Change Password to take effect, re-login Welcome to the MySQL Monitor. Commands End With; or \g.your MySQL connection ID is 1Server version:5.1.73 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.
This article is from "Linux rookie" blog, please be sure to keep this source http://490617581.blog.51cto.com/11186315/1758780
Root password reset for MySQL