MySQL添加用户、删除用户与授权
发布日期:2025-04-18 02:02:42 浏览次数:19 分类:精选文章

本文共 1471 字,大约阅读时间需要 4 分钟。

MYSQL ??????

1. ????

1.1 ??MYSQL

????????MYSQL?

@> mysql -u root -p

?????????

@> ??

1.2 ????

???????????

@> mysql> CREATE USER 'test'@'%' IDENTIFIED BY '1234';
  • "test"????
  • "1234"???
  • "%"?????????????????????
  • ???????????????? "%" ??? 127.0.0.1

1.3 ????

??????????

@> mysql -u test -p

??????????

@> ????@> ????

2. ????

2.1 ???????

?? grant ??????????

@> grant ?? on ???.* to ???@???? identified by "??";

???????? testDB ?????????

@> grant all privileges on testDB.* to test@localhost identified by '1234';@> flush privileges;

2.2 ???????

???????

@> grant select,update on testDB.* to test@localhost identified by '1234';@> flush privileges;

2.3 ???????

???????????????????

@> grant select,delete,update,create,drop,insert on *.* to test@"%" identified by "1234";
  • "%" ??????????????? localhost?
  • ? localhost ???? "@"%" ??? localhost ??

2.4 ????????

?????????

@> drop user test@%;@> drop user test@localhost;

3. ????

3.1 ??????

???????????

@> mysql -u root -p@> delete from user where User='test' and Host='localhost';@> flush privileges;

3.2 ???????

???????????

@> drop database testDB;

4. ??????

4.1 ?? update ??

???????

@> mysql -u root -p@> update mysql.user set password=password('???') where User="test" and Host="localhost";@> flush privileges;

5. ???????

????????

@> show databases;

6. ?????

?????????

@> use '????';

7. ?????

?????????

@> show tables;

8. ?????

????????

@> describe ??;

9. ???????

??????

@> drop database ????;

????

@> drop table ??;

??????? root ???????

上一篇:mysql添加用户及权限
下一篇:mysql添加用户

发表评论

最新留言

第一次来,支持一个
[***.219.124.196]2026年06月01日 11时18分32秒