1、create schema [數據庫名稱] default character set utf8 collate utf8_general_ci;--創建數據庫
采用create schema和create database創建數據庫的效果一樣。
2、create user '[用戶名稱]'@'%' identified by '[用戶密碼]';--創建用戶
密碼8位以上,包括:大寫字母、小寫字母、數字、特殊字符
%:匹配所有主機,該地方還可以設置成‘localhost’,代表只能本地訪問,例如root賬戶默認為‘localhost‘
3、grant select,insert,update,delete,create on [數據庫名稱].* to [用戶名稱];--用戶授權數據庫
*代表整個數據庫
4、flush privileges ;--立即啟用修改
5、revoke all on *.* from tester;--取消用戶所有數據庫(表)的所有權限
6、delete from mysql.user where user='tester';--刪除用戶
7、drop database [schema名稱|數據庫名稱];--刪除數據庫