Linux环境 Mysql新建用户并授权

By Mac小兔

新建用户

1
2
3
4
create user 'username'@'localhost' identified by '******';
grant all privileges on databasename.* to username@ip identified by '******';
# grant all privileges on databasename.* to username@'%' identified by '******';
flush privileges;

删除用户

1
2
3
4
delect from user where user='username' and Host='localhost';

drop user username@'%';
drop user username@localhost;

改指定用户password

1
2
update mysql.user set password=password('新密码') where User='username' and Host="localhost";
flush privileges;
Link.