mysql常用命令
目录:
mysql常用命令
- 看所有线程:
show full processlist;
- 杀死进程:
kill 60882 ;
- 查看当前未提交的事务: ` select * from information_schema.innodb_trx;`
- 查看用户下的线程:
select * from information_schema.PROCESSLIST;
- 查看当前未提交的事务:
select * from information_schema.innodb_trx;
- 查看锁等待情况:
select * from information_schema.INNODB_LOCK_WAITS;
- 查看当前持有锁情况:
select * from information_schema.INNODB_LOCKS;
- 查看系统状态:
SHOW ENGINE INNODB STATUS;
- 查看binlog:
show binary logs;
- 查看binlog日志路径:
show variables like 'log_%';
- 解析binlog:
mysqlbinlog --no-defaults -d databasename --start-datetime="2017-09-17 07:21:09" --stop-datetime="2017-09-19 07:59:50" mysql-bin.000002
my2sql binlog日志解析
1
2
3
4
5
# 解析本地binlog,指定数据库在指定日期范围内执行的sql
./my2sql -user root -password '2vKeG&1.3' -host 127.0.0.1 -port 7501 -databases db_transfer -mode file -local-binlog-file ./binlog.000009 -start-datetime "2023-08-04 09:20:00" -stop-datetime "2023-08-04 09:50:00" -start-file binlog.000009 -work-type 2sql -output-dir ./tmpdir
# 解析本地binlog,指定数据库在指定日期范围内执行的sql,并生成回滚sql
./my2sql -user root -password '2vKeG&1.3' -host 127.0.0.1 -port 7501 -databases db_transfer -mode file -local-binlog-file ./binlog.000009 -start-datetime "2023-08-04 09:20:00" -stop-datetime "2023-08-04 09:50:00" -start-file binlog.000009 -work-type rollback -output-dir ./tmpdir
mysql用户及授权
1
2
3
4
5
6
7
8
9
-- 创建用户test密码123456,并运行从任意IP链接
create user 'test'@'%' identified by '123456';
-- 赋予test用户 test,db_monitor 库的所有权限
grant all privileges on test.* to 'test'@'%';
grant all privileges on db_monitor.* to 'test'@'%';
-- 只赋予查询权限
grant select on db_monitor.* to 'test'@'%';
This post is licensed under CC BY 4.0 by the author.