MySQL日常维护指南
2024-10-21 23:28:52
一、常用命令
1、查看数据库默认编码
show variables like 'character%';
show variables like 'collation%';
2、启动停止数据库
/etc/init.d/mysql start (stop)
3、创建数据库
create database if not exists 数据库名 default charset gbk collate gbk_chinese_ci;
create database if not exists 数据库名 default charset gbk collate gbk_bin;
create database if not exists 数据库名 default charset utf8mb4 collate utf8mb4_unicode_ci;
4、创建数据表
create table 表名 (
......
) engine=InnoDB default charset=utf8mb4 collate=utf8mb4_unicode_ci;
5、查看表当前字符集
show cereate table 表名;
6、查看字符集的排序规则
show collation
7、查看表类型
show create table tablename
8、创建用户并授权
grant all on 数据库名.* to '用户名'@'%' identified by '密码';
flush privileges;
或
create user '用户名'@'%' identified by '密码';
grant all on 数据库名.* to '用户名'@'%';
flush privileges;
9、权限撤销
revoke 权限名 on 数据库名.表名 from 用户名@主机名;
10、查看for update超时时间设置
show global variables like "%timeout%";
set global innodb_lock_wait_timeout = 10;
11、查看正在锁和等待锁的事务
select * from information_schema.innodb_locks;
select * from information_schema.innodb_lock_waits;
二、概念解释
1、什么是collate?
2、engine=lnnoDB 和 MyISAM的区别?
最新文章
- SQL高级查询:嵌套和分页
- MMORPG大型游戏设计与开发(客户端架构 part2 of vgui)
- 10. JEB1.5 插件编写二
- php单链表实现的代码
- javaweb学习总结(三十九)——数据库连接池
- Eclipse启动时报需要安装";Java SE 6 Runtime";致无法启动解决方案
- Jafka来源分析——文章
- hdu 5625 Clarke and chemistry
- 使用java对执行命令行 或 执行bat文件
- 牛客 小a与星际探索 bfs
- linux上mongodb的安装与卸载
- vue教程2-04 vue实例简单方法
- RHEL7--linux系统启动流程与故障排除
- Scala_运算符
- Android:EditText 属性
- 1 python使用networkx或者graphviz,pygraphviz可视化RNN(recursive)中的二叉树
- SOJ4389 川大贴吧水王 队列
- 如何用dva来构建你的应用
- LeetCode 简单 - 最大子序和(53)
- HTML5/CSS3 第二章页面组件