mysql -u root -p
password
use mysql
insert into user(host,user,password) values('localhost','hail',password('hail'))
flush privileges
create database haildb
grant all privileges on haildb.* to hail@localhost identified by 'hail'
flush privileges
如果想指定部分权限给用户
grant select,update on haildb.* to hail@localhost identified by 'hail'
flush privileges
删除用户
delete from user where user='hail' and host='localhost'
flush privileges
删除用户数据库
drop database haildb
修改指定用户密码
update user set password=password('new_password') where user='hail' and host='localhost'
flush privileges
使用户不具有Create User权限或者deny Create User权限下面是权限列表
mysql>show privileges \G
*************************** 1. row ***************************
Privilege: Alter
Context: Tables
Comment: To alter the table
*************************** 2. row ***************************
Privilege: Alter routine
Context: Functions,Procedures
Comment: To alter or drop stored functions/procedures
*************************** 3. row ***************************
Privilege: Create
Context: Databases,Tables,Indexes
Comment: To create new databases and tables
*************************** 4. row ***************************
Privilege: Create routine
Context: Databases
Comment: To use CREATE FUNCTION/PROCEDURE
*************************** 5. row ***************************
Privilege: Create temporary tables
Context: Databases
Comment: To use CREATE TEMPORARY TABLE
*************************** 6. row ***************************
Privilege: Create view
Context: Tables
Comment: To create new views
*************************** 7. row ***************************
Privilege: Create user
Context: Server Admin
Comment: To create new users
*************************** 8. row ***************************
Privilege: Delete
Context: Tables
Comment: To delete existing rows
*************************** 9. row ***************************
Privilege: Drop
Context: Databases,Tables
Comment: To drop databases, tables, and views
*************************** 10. row ***************************
Privilege: Event
Context: Server Admin
Comment: To create, alter, drop and execute events
*************************** 11. row ***************************
Privilege: Execute
Context: Functions,Procedures
Comment: To execute stored routines
*************************** 12. row ***************************
Privilege: File
Context: File access on server
Comment: To read and write files on the server
*************************** 13. row ***************************
Privilege: Grant option
Context: Databases,Tables,Functions,Procedures
Comment: To give to other users those privileges you possess
*************************** 14. row ***************************
Privilege: Index
Context: Tables
Comment: To create or drop indexes
*************************** 15. row ***************************
Privilege: Insert
Context: Tables
Comment: To insert data into tables
*************************** 16. row ***************************
Privilege: Lock tables
Context: Databases
Comment: To use LOCK TABLES (together with SELECT privilege)
*************************** 17. row ***************************
Privilege: Process
Context: Server Admin
Comment: To view the plain text of currently executing queries
*************************** 18. row ***************************
Privilege: Proxy
Context: Server Admin
Comment: To make proxy user possible
*************************** 19. row ***************************
Privilege: References
Context: Databases,Tables
Comment: To have references on tables
*************************** 20. row ***************************
Privilege: Reload
Context: Server Admin
Comment: To reload or refresh tables, logs and privileges
*************************** 21. row ***************************
Privilege: Replication client
Context: Server Admin
Comment: To ask where the slave or master servers are
*************************** 22. row ***************************
Privilege: Replication slave
Context: Server Admin
Comment: To read binary log events from the master
*************************** 23. row ***************************
Privilege: Select
Context: Tables
Comment: To retrieve rows from table
*************************** 24. row ***************************
Privilege: Show databases
Context: Server Admin
Comment: To see all databases with SHOW DATABASES
*************************** 25. row ***************************
Privilege: Show view
Context: Tables
Comment: To see views with SHOW CREATE VIEW
*************************** 26. row ***************************
Privilege: Shutdown
Context: Server Admin
Comment: To shut down the server
*************************** 27. row ***************************
Privilege: Super
Context: Server Admin
Comment: To use KILL thread, SET GLOBAL, CHANGE MASTER, etc.
*************************** 28. row ***************************
Privilege: Trigger
Context: Tables
Comment: To use triggers
*************************** 29. row ***************************
Privilege: Create tablespace
Context: Server Admin
Comment: To create/alter/drop tablespaces
*************************** 30. row ***************************
Privilege: Update
Context: Tables
Comment: To update existing rows
*************************** 31. row ***************************
Privilege: Usage
Context: Server Admin
Comment: No privileges - allow connect only
31 rows in set (0.00 sec)
mysql>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)