1、进入docker下mysql

  docker exec -it 容器ID /bin/bash

  mysql -uroot -p

2、修改用户密码

  UPDATE user SET password = PASSWORD('newpassword') where USER='root'; // password ==> authentication_string

  flush privileges;

3、创建新用户

  CREATE USER ‘test’@’%’ IDENTIFIED BY ‘123456’;

或者

  insert into user(host,user,authentication_string) values('%','test',password('123456'));

4、授权

  grant all on *.* to 'test'@'%' identified by '123456' with grant option; // 授所有权限

  flush privileges;

  SHOW GRANTS FOR 'test'@'%'; // 查看授权

  

   revoke all on user.* from 'test'@'%'; 

5、删除用户

  delete from user where user=’test’ and host=’%’;

 

posted on 2022-11-11 18:26  子衿-悠心  阅读(25)  评论(0)    收藏  举报