MySQL Change Password method summary

Source: Internet
Author: User
Tags mysql insert mysql flush privileges

Method One
using phpMyAdmin, this is the simplest, modify the MySQL library's user table,
but don't forget to use the password function.

Method Two
using Mysqladmin, this is a special case of the preceding declaration.
mysqladmin-u root-p Password mypasswd
after entering this command, you need to enter the root's original password, then the root password will be changed to MYPASSWD.
change the root of the command to your username, and you can change your own password.
of course if your mysqladmin is not connected to MySQL server, or you have no way to execute mysqladmin,
then this method is ineffective.
and mysqladmin can't erase the password.

Method 3: Use the Set password command

Mysql-u Root

mysql> SET PASSWORD for ' root ' @ ' localhost ' = PASSWORD (' Newpass ');

Method 4: Edit the user table directly with update

Mysql-u Root

mysql> use MySQL;

mysql> UPDATE user SET Password = Password (' newpass ') WHERE user = ' root ';

mysql> FLUSH privileges;

Method 5
MySQL INSERT into Mysql.user (Host,user,password)
VALUES ('% ', ' Jeffrey ', PASSWORD (' biscuit '));
MySQL FLUSH privileges
Specifically, this is the addition of a user named Jeffrey, with a password of biscuit.
There is this example in the MySQL Chinese reference manual, so I wrote it out.
Note that you want to use the password function, and then you also use the flush privileges.

Method 6
As with method Three, just use the Replace statement
MySQL REPLACE into Mysql.user (Host,user,password)
VALUES ('% ', ' Jeffrey ', PASSWORD (' biscuit '));
MySQL FLUSH privileges

This can be done when the root password is lost

Mysqld_safe--skip-grant-tables&

Mysql-u Root MySQL

mysql> UPDATE user SET Password=password ("New password") WHERE user= ' root ';

mysql> FLUSH privileges;



This article is from the "Dream to Reality" blog, please be sure to keep this source http://lookingdream.blog.51cto.com/5177800/1881696

MySQL Change Password method summary

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.