创建用户
5.7+版本中不能使用
insert into mysql.user的方式创建用户
CREATE USER 'test'@'localhost' IDENTIFIED BY '1234'; #本地登录CREATE USER 'test'@'%' IDENTIFIED BY '1234'; #远程登录
授权
# 创建数据库create database testDB;create database testDB default charset utf8 collate utf8_general_ci;# 全部授权grant all privileges on testDB.* to "test"@"%" identified by '1234';# MySQL8.0+grant all privileges on testDB.* to "test"@"%" with grant option;#刷新系统权限表flush privileges;# 部分授权grant select,update on testDB.* to "test"@"localhost" identified by '1234';
删除用户
DELETE FROM mysql.user WHERE User='test' and Host='localhost';flush privileges;drop database testDB;drop user 'test'@'%';drop user 'test'@'localhost';
修改密码
5.7+版本中不再有
Password字段,取而代之的是authentication_string
update mysql.user set authentication_string=password(“新密码”) where User=”test” and Host=”localhost”;
