#使用grant创建账户
grant all on 数据库.数据表 to '用户名'@'主机信息' identified by '用户密码';
grant all on . to 'yjwh'@'localhost' identified by '123456';
flush privileges;
删除用户
#案例1:删除harry账号
drop user 'harry'@'localhost';
数据库的权限管理
#查看当前用户(自己)权限:
show grants;
#查看其他 MySQL 用户权限:
show grants for dba@localhost;
grant 高级 DBA 管理 MySQL 中所有数据库的权限
#这个不行换下一个
grant all on *.* to 'dba'@'localhost'
grant all privileges on *.* to 'yjwh'@'%' identified by '123456';
set password for 'root'@'%'=password('MyNewPass4!');
数据库的增删改查
#查询有所有库
show databases;
#创建库
create database dbname
#查看某一个数据库
show create database dbname
#使用数据库
use 库名;
#看看当前use了哪个库
select database()
#删除库
drop database 数据库名;
数据表的增删改查
#修改数据表中的数据
update 数据表名称 set 字段1=字段1的值,字段2=字段2的值 where 条件;
update user set host='111111' where host='localhost' and user='yjwh';
#如果有2个条件用and连接#删除或清空数据
delete from 数据表 where 条件
delete from user where user='yjwh' and host='111111';
#查询数据
select * from 表名;--查看整个表
select 字段值1,字段值2 from scores;--查看仅含有字段值1和字段值2的数据内容
select * from 表名 where 条件
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)