创建用户: create user 'alex'@'192.168.1.1' identified by '123123'; 用户名为alex, 密码是'123123', 服务器的ip ‘192.168.1.1’
create user 'alex'@'192.168.1.%' identified by '123123'; 用户名为alex, 密码是'123123', 服务器的ip为'192.168.1.%'
create user 'alex'@'%'identified by '123123' ; 用户名为alex, 密码是'123123',服务器的ip为'%'
用户ip登录: mysql -h localhost -u root -p
删除用户: drop user 'alex'@'192.168.1.1'
修改用户: rename user 'alex'@'192.168.1.1' to 'alex'@'192.168.1.2'
修改密码: set password for 'alex'@'192.168.1.2' = '123456'
查看当前用户: select host,userfrom user;
授权: grant select, insert, update on db1.* to 'alex'@'%' 对alex用户进行db1数据库的所有表的查询,插入,修改操作
grant all privileges on db1.t1 to 'alex'@'%'; 对alex用户进行db1数据库的表t1的所有操作授权
remove all privileges on db1.t1 from 'alex'@'192.168.1.1'; 将alex用户对于db1中表t1的权限删除