Forget the original root password of myql

Source: Internet
Author: User
Tags pkill

Forget the original root password of myql
1. Have the original root password for myql;


Method 1:
Outside the mysql system, use mysqladmin
# Mysqladmin-u root-p password "test123"
Enter password: [Enter the original password]

Method 2:
Log on to the mysql system,
# Mysql-uroot-p
Enter password: [Enter the original password]
Mysql> use mysql;
Mysql> update user set password = passworD ("test") where user = 'root ';
Mysql> flush privileges;
Mysql> exit;



2. Forget the original root password of myql;

First, you must have the root permission of the operating system. If you do not have the root permission of the system, consider the root system and then follow the steps below.
Similar to logging on to the system in safe mode, it is recommended that you use pkill mysql, but I do not recommend it. Because when you execute this command, it will lead to the following situation:
/Etc/init. d/mysqld status
Mysqld dead but subsys locked
In this way, even if you start mysql in safe mode, it may not be useful. d/mysqld stop. If you use pkill, start and stop again.
# Mysqld_safe -- skip-grant-tables &
&, Indicating that it is running in the background. If it is no longer running in the background, open another terminal.
# Mysql
Mysql> use mysql;
Mysql> UPDATEuserSETpassword = password ("test123") WHEREuser = 'root ';
Mysql> flush privileges;
Mysql> exit;
# Mysql is case-insensitive, but this is the specific value of the modified mysql database. Note that.

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.