MySQL new user's method

Source: Internet
Author: User

NewInsert  intoMysql.User(Host,User, Password,ssl_cipher,x509_issuer,x509_subject)Values("localhost", "CZ", Password ("cz2@14"),"',"',"'); FlushPrivileges;Create Databaseczdb;Grant  All Privileges  onCzdb.*  toCz@localhostIdentified by '[email protected]'; FlushPrivileges; DeleteDELETE  from User WHERE User="CZ" andHost="localhost"; flushPrivileges;Drop Databaseczdb; Modify the specified user passwordUpdateMysql.User SetPassword=Password'New Password')where User="CZ" andHost="localhost"; flushPrivileges;

First of all, to declare: In general, to modify the MySQL password, authorization, is required to have the root authority in MySQL.

Note:This operation is at the win command prompt, phpMyAdmin also applies.
User: Phplamp user database: phplampdb

1. Create a new user.

Log in to MySQL
@>mysql-u root-p
@> Password
Create user
mysql> INSERT INTO Mysql.user (host,user,password,ssl_cipher,x509_issuer,x509_subject) VALUES ("localhost", " Pppadmin ", Password (" 1234 "), ', ', ', ');
Refresh System Permissions Table
Mysql>flush privileges;
This creates a user named: Phplamp with a password of: 1234.

Then log in.

mysql>exit;
@>mysql-u phplamp-p
@> Enter password
Mysql> Login Successful

2. Authorize the user.

Log in to MySQL (with root privileges). I am logged in as root.
@>mysql-u root-p
@> Password
First create a database for the user (phplampdb)
Mysql>create database phplampdb;
Authorizes the Phplamp user to have all the permissions of the Phplamp database.
>grant all privileges in phplampdb.* to [e-mail protected] identified by ' 1234 ';
Refresh System Permissions Table
Mysql>flush privileges;
Mysql> Other operations

/*
If you want to specify partial permissions to a user, you can write:
Mysql>grant select,update on phplampdb.* to [e-mail protected] identified by ' 1234 ';
Refreshes the System permissions table.
Mysql>flush privileges;
*/

3. Delete the user.
@>mysql-u root-p
@> Password
Mysql>delete from user WHERE user= "phplamp" and host= "localhost";
Mysql>flush privileges;
Delete a user's database
Mysql>drop database phplampdb;

4. Modify the specified user password.
@>mysql-u root-p
@> Password
Mysql>update Mysql.user Set Password=password (' New password ') where user= "Phplamp" and host= "localhost";
Mysql>flush privileges;

Another article reproduced, pay attention not to ignore the flush privileges

Method One:
Mysql>use MySQL
Mysql>grant SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER
On *. * to identified by ' password ';
Mysql>grant all privileges in mydb.* to "
Identified by ' password ';
Mysql>grant PROCESS, FILE on *. * to
Identified by ' password ' WIDTH GRANT OPTION;

The above statement adds three users. Users with "J E R y" as their user name on this computer will have the
The permissions listed above for s e L e C T, I N S e RT, etc. And the user J I m on whatever host login has the database m y d b
All permissions (not including G R A N-t permissions). The user "L e o n" from "s e R v e R d o m a n" has P r o C e s S,
F I L E and g R A N t permission.

Method Two:
Mysql>use MySQL
Mysql>insert into user VALUES (' localhost ', ' Jerry ', PASSWORD (' PASSWORD '),
' Y ', ' y ', ' y ', ' y ', ' y ', ' y ', ' y ', ' n ', ' n ', ' n ', ' n ', ' n ', ' n ', ' Y ', and so on;
Mysql>insert into User (Host, user, Password)
VALUES ('% ', ' Jim ', PASSWORD (' PASSWORD '));
Mysql>insert into db (Host, DB, User,
Select_priv, Insert_priv, Update_priv, Delete_priv, Create_priv, Drop_priv, Alter_priv)
VALUES ('% ', ' Jim ', ' y ', ' y ', ' y ', ' y ', ' y ', ' y ', ' y ');
Mysql>insert into User VALUES (' server.domain ', ' Leon ', PASSWORD (' PASSWORD ')
' n ', ' n ', ' n ', ' n ', ' n ', ' n ', ' n ', ' n ', ' y ', ' y ', ' y ', ' n ', ' n ', ' n ');
Mysql>flush privileges;

The above statement adds three users who have the same permissions as in method one. The value of the above VA L U E s item should be with M y s q L
The corresponding items in the corresponding table in the database are in the same order. Not necessarily in the order above, maybe the number of items will be different.
Because the permissions of the 一、三个 user are all "*." * ", so do not insert a record in the D B table.

Reprint: http://hi.baidu.com/pegasus827/blog/item/8b6e1d3c125d60e63c6d970c.html

MySQL new user's method

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.