1. mysql Login without password
[Email protected] ~]# Mysql-uroot
2. mysql Setup password
[Email protected] ~]# mysqladmin-uroot password ' daixuanlinux '
3. mysql Change password
[[email protected] ~]# mysqladmin-uroot-p original password password new password
4, MySQL designated root user password login
[Email protected] ~]# Mysql-uroot-pdaixuanlinux
5. Forgot the root password of MySQL, how to change it?
(1) Editing the MySQL configuration file
[[email protected] ~]# VIM/ETC/MY.CNF not authorized
Skip-grant
(2) Restart MySQL service
[Email protected] ~]#/etc/init.d/mysqld restart
(3) Call the MySQL library and reset the password
[[email protected] ~]# MySQL can be accessed directly after the restart
mysql> use MySQL library with MySQL
mysql> Update user Set Password=password (' Daixuan ') where user= ' root '; reset root password to Daixuan
Query OK, 3 rows affected (0.01 sec)
(4) Modify the configuration file to enable authorization, restart MySQL, log in again to specify the user name password, or error, indicating that the password modified successfully
[[email protected] ~]# VIM/ETC/MY.CNF authorized
#skip-grant
[Email protected] ~]#/etc/init.d/mysqld restart
[[email protected] ~]# MySQL does not specify user name password login failed
ERROR 1045 (28000): Access denied for user ' root ' @ ' localhost ' (using Password:no)
[[email protected] ~]# Mysql-uroot-pdaixuan Specify user name password, login successful
Mysql>
This article is from the "Daixuan" blog, make sure to keep this source http://daixuan.blog.51cto.com/5426657/1720114
Root password reset for MySQL