Root password reset for MySQL

Source: Internet
Author: User

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

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.