Linux under MySQL forget root password

Source: Internet
Author: User
Tags mysql in safe mode

If you accidentally forget the root password, or as I do wrong operation of the root permissions to the minimum, you do not have to panic, use the following steps to easily retrieve the password:


Method One


1. Run MySQL in safe mode and skip security verification


/usr/bin/mysqld_safe--skip-grant-tables

2, as root login MySQL

The code is as follows Copy Code

/usr/bin/mysql-uroot

3, reset, empty the root password

The code is as follows Copy Code
mysql> use MySQL;
mysql> Update user set password= ' where user= ' root ';

4. Reset Password to root

The code is as follows Copy Code

/usr/bin/mysqladmin-uroot password ' Your password here '

Method Two


using the Reset script

The code is as follows Copy Code

wget Http://soft.vpser.net/lnmp/ext/reset_mysql_root_password.sh;sh reset_mysql_root_password.sh

Suitable for LNMP or MySQL admin scripts in/etc/init.d/mysql and MySQL installed in/usr/local/mysql/. Otherwise, you will need to modify the script before performing the SH reset_mysql_root_password.sh.

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.