MySQL Password modification

Source: Internet
Author: User

First, using mysqladmin to change the password

1.root User no password

# mysqladmin-u root password 123456 # change Password to 123456:


2.root has password (123456), change password to abcdef:

# mysqladmin-u root-p password abcdef

Note that the command will ask you the old password, enter the old password 123456 after the command completes, the password modification succeeds.


Second, the root of the original myql password;

method One: Outside the MySQL system, use mysqladmin

# mysqladmin-u root-p password "test123"

Enter Password: "Enter the original password"

Method two: By logging into the MySQL system,

# mysql-uroot-p Enter Password: "Enter your original password"


mysql> use MySQL; #进入mysql数据库

mysql> Update user set Password=password (' 123456 ') where user= ' root '; #修改root密码为12345

mysql> flush privileges; #刷新权限

mysql> exit;

Third, forget the original MYQL root password

1. Modify the MySQL configuration file

# vim/etc/my.cnf

Join in [MYSQLD] Paragraph

skip-grant-tables #跳过验证

# service mysqld restart #重启MySQL


2. Connect MySQL

# mysql-uroot

Mysql>use MySQL #进入mysql数据库

mysql> Update user set Password=password (' 123456 ') where user= ' root '; #修改root密码为12345

mysql> flush privileges; #刷新权限

mysql> exit ;


3. Change back to MySQL configuration file

# vim/etc/my.cnf

Log out of Skip-grant-tables

# service mysqld restart #重启MySQL

This article is from the "Garany.wang" blog, make sure to keep this source http://garany.blog.51cto.com/7342714/1760338

MySQL Password modification

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.