为MySQL数据库分配指定用户

日常语句

-- 创建用户
create user kanyme identified by 'kanyme';

-- 授权
grant all privileges on kanyme_db.* to kanyme@'%';
-- 刷新权限
flush privileges;

-- 查看权限
show grants for 'kanyme';

-- 修改密码
update mysql.user set password = password('kanyme_new') where user = 'kanyme' and host = '%';

-- 新版
alter user'root'@'%' identified by 'kanyme_new';
flush privileges;

-- 删除用户
drop user kanyme@'%';

-- 修改Root用户密码
update mysql.user set authentication_string="kanyme_new" WHERE user="root";
flush privileges;

mysql 5.7.9 之后取消了password 函数,authentication_string=password(“123456”) 会报错