创建用户
mysql> create user 'mr.robot'@'myhost.com' identified by [password] 'your_password';
授权(权限存储在mysql数据库中的user, db, host, tables_priv, columns_priv, procs_priv这些表中)
基本语句结构: grant privileges [columns] on item to user_info [identified by password | identified with [auth_plugin] [as auth_string]] [require ssl_options] [with grant option | limit_options]; privileges结构(3种类型权限): 普通用户权限:select, insert, update, delete, index, alter, create, drop, event, trigger, create view, show view, proxy, create routine, execute, alter routine 管理员权限:create tablespace, create user, create temporary tables, file, lock tables, process, reload, replication client, replication slave, show databbases, shutdown, super 特殊权限:all(前面所有的权限), usage(只能登陆) item结构:*.*, mydb.*, mydb.mytable limit_options结构:max_queries_per_hour n, max_updates_per_hour n, max_connection_per_hour n, max_user_connections n mysql> grant insert on test.* to 'mr.robot'@'localhost' with max_queries_per_hour 100;
回收权限
基本语句结构: revoke privileges [(columns)] on item from user_name; mysql> revoke insert, grant option from 'mr.robot'@'localhost';
刷新权限表
mysql> flush privileges;
SQL中的三种类型语句
1.DDL(Data Definiton Language) -- 数据定义语言 create, alter, drop 2.DML(Data Manipulation Language) -- 数据操作语言 insert, delelte, update, select 3.DCL(Data Control Language) -- 数据控制语言 grant, revoke, deny等
SQL中的注释语句
create database database_x --创建数据库database_x,这是单行注释 create database database_x /* 创建一个数据库 名字叫做database_x 这是多行注释 */