Mysql adds and deletes users and assigns permissions _ MySQL

Source: Internet
Author: User
Mysql adds and deletes users and assigns bitsCN.com permissions.

1. add a user


Mysql> insert into mysql. user (Host, User, Password) values ("localhost", "lionbule", password ("hello1234 "));
Mysql> flush privileges;

2. change the user password


Mysql> update mysql. user set password = password ('New password') where User = "lionbule" and Host = "localhost ";
Mysql> flush privileges;

3. delete a user


Mysql> delete from user WHERE User = "lionbule" and Host = "localhost ";
Mysql> flush privileges;

4. Permission Assignment

4.1. grant usage
Grant permission on database. * to username @ 'login host' identified by 'password'


Permission:
Common Summary: ALL/ALTER/CREATE/DROP/SELECT/UPDATE/DELETE
Database:
*. * Indicates all tables in all databases.
Test. * indicates all tables in the test database.
Test. test_table indicates the test_table table of the test database.
User name:
Mysql account name
Login host:
Client ip addresses allowed to log on to mysql server
'%' Indicates all ip addresses
'Localhost' indicates the local machine
'1970. 168.10.2 'specific IP address
Password:
Logon password for the account

4.2 Example


Mysql> grant all on test. * to lionbule @ '%' identified by 'hello1234 ';
Mysql> flush privileges;

Lionbule, the user with the new password 'hello234', has all operation permissions on the test database and does not limit the logon IP address of lionbule users.

4.3 precautions

Grant overwrites some user information, which is the same as the insert and update operations.

Refer:
Http://dev.mysql.com/doc/refman/5.6/en/grant.html

BitsCN.com

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.