MySQL Basic operation

Source: Internet
Author: User

#访问控制

# #登录mysql

Mysql-u root-p

# #查看所有用户

Select User from Mysql.user

# #创建用户

CREATE USER ' username ' @ ' host ' identified by ' password ';

# #删除用户

Note that you must explicitly give the hostname of the account

Drop user ' test ' @ ' localhost ';

# #重命名用户

Rename user ' test ' @ ' localhost ' to ' foo ' @ ' localhost ';

# #修改密码

Set password for ' test ' @ ' localhost ' =password (' hello ');

#权限管理

# #查看权限

Show grants for ' test ' @ ' localhost ';

# #授权

Grant Select (Cust_id,cust_name)    on mysql_test.customers    to ' zhangsan ' @ ' localhost ';--Grant in the database Mysql_ Test has SELECT permission on the table customers for columns cust_id and columns Cust_name

  

Grant SELECT, update on    mysql_test.customers    to ' liming ' @ ' localhost ' identified by ' 123 ';--Create a new user for liming, and grant it permission to have select and update on the table customers of the database Mysql_test

  

Grant    all on mysql_test.* to ' zhangsan ' @ ' localhost ';--grant permission to perform all operations in the database Mysql_test

  

Grant create user    on *    . * to ' zhangsan ' @ ' localhost ';--grant the user Zhangsan already present in the system.

# #权限的转移

Grant Select,update on    mysql_test.customers to    ' Zhou ' @ ' localhost ' identified by ' 123 ' with    grant option;

If the above with clause is followed by the

Max_queries_per_hour Count,
Max_updates_per_hour Count,
Max_connections_per_hour Count,
Max_user_connections Count
, the grant statement can be used to restrict permissions

Grant Delete on    mysql_test.customers to    ' zhangsan ' @ ' localhost ' with    max_queries_per_hour 1;-- Permission to process only one DELETE statement per hour

# #权限的撤销

Revoke select     on Mysql_test.customers    from ' zhangsan ' @ ' localhost ';--Recycle user Zhangsan in database mysql_ Select permission on table customers of test

Transported from http://blog.csdn.net/ParanoidYang/article/details/61951265

MySQL Basic operation

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.