MySQL Account management

Source: Internet
Author: User

1. Create a new normal user


--create statements

mysql> create user ' test1 ' @ ' localhost ' identified by ' test1 ';


--Inserting with insert

mysql> INSERT INTO Mysql.user (host,user,password,ssl_cipher,x509_issuer,x509_subject) VALUES (' localhost ', ' test2 ', password (' test2 '), ', ', ', ');

mysql> flush Privileges;


--Using the GRANT statement

Mysql> Grant SELECT On * * to ' test3 ' @ ' localhost ' identified by ' test3 ';

mysql> flush Privileges;


2. Delete a normal user


--drop Delete

mysql> drop user ' test1 ' @ ' localhost ';


--Delete from table using delete

Mysql> Delete from mysql.user where host= ' localhost ' and user= ' test2 ';

mysql> flush Privileges;


3.root Change Password


----root to change the root password

--mysqladmin modification

[Email protected] ~]# mysqladmin-uroot-p password

Enter Password:

New Password:

Confirm New Password:


--Use Update to change after login

mysql> Update Mysql.user Set Password=password (' root ') where host= ' localhost ' and user= ' root ';

mysql> flush Privileges;


--use Set to modify after login

Mysql> set Password=password (' root ')

mysql> flush Privileges;


----ROOT to modify a normal user password

--set statements

mysql> set password for ' test3 ' @ ' localhost ' =password (' test3 ');


--update Update Mysql.user Table

mysql> Update Mysql.user Set Password=password (' Test3 ') where host= ' localhost ' and user= ' test3 ';

mysql> flush Privileges;


--grant statements

Mysql> Grant SELECT On * * to ' test3 ' @ ' localhost ' identified by ' test3 ';

After Grant modifies the password, the previous authorization for the user to use the old password is still


4. Ordinary users to change their own password


Mysql> set Password=password (' test4 ');

Ordinary users generally cannot use Mysqladmin


5.root Password Loss


[Email protected] ~]# VIM/ETC/MY.CNF

[Mysqld]

Skip-grant-tables


[Email protected] ~]#/etc/init.d/mysqld restart

[[email protected] ~]# MySQL

Mysql>

mysql> Update Mysql.user Set Password=password (' root ') where host= ' localhost ' and user= ' root ';

mysql> flush Privileges;


Note: Use mysql-5.5.30

This article is from the "popular sui" blog, please be sure to keep this source http://8722413.blog.51cto.com/8712413/1542400

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.