1、创建数据库
#不指定字符创建 create database kodbox?character; #指定utf8字符创建 create database kodbox character set utf8;
2、创建用户
#创建用户kodbox,仅限本机访问,密码123456 create user 'kodbox'@'localhost' identified by '123456'; #创建用户kodbox,仅限192.168.124.3访问,密码123456 create user 'kodbox'@'192.168.124.3' identified by '123456'; #创建用户kodbox,所有IP可以访问,密码123456 create user 'kodbox'@'%' identified by '123456';
3、授权
#将数据库kodbox授权给用户kodbox grant all privileges on kodbox.* to 'kodbox'@'%';? #刷新权限 flush privileges;
4、查看数据库
show databases;
?5、查看用户
?select user,host from mysql.user;?
?6、删除数据库、用户
删除数据库:drop database kodbox;
删除用户:drop user 'kodbox'; 或者 drop user 'kodbox'@'%';
|