#查看数据库中某个数据库中占据空间较大的前几位
mysql -uroot -p密码 -hIP -A -e"select TABLE_SCHEMA as "数据库",TABLE_NAME as "表名",DATA_LENGTH/1024/1024 from information_schema.TABLES where TABLE_SCHEMA='yt_log' order by DATA_LENGTH desc;" | head -n 10
#查看数据库的大小
mysql -uroot -p密码 -hIP -A -e"select TABLE_SCHEMA as "数据库",sum(DATA_LENGTH/1024/1024) from information_schema.TABLES group by table_schema order by sum(DATA_LENGTH) desc;"
#通过mysql的变量配置表,查看二进制日志是否已开启
mysql -uroot -p密码 -hIP -A -e"show variables like 'log_%';"
#获取binlog文件列表
show binary logs;
#查看当前正在写入的binlog文件
mysql -uroot -p密码 -h192.168.1.37 -A -e"show master status;"
#怎么删binlog
例如:purge master logs to "binlog_name.00000X"
#是否启用binlog日志
show variables like 'log_bin';
#查看详细的日志配置信息
show global variables like '%log%';
#mysql数据存储目录
show variables like '%dir%';
# 查看binlog的目录
show global variables like "%log_bin%";
#查看数据库的编码
show variables like 'character%';
character_set_client:为客户端编码方式
character_set_connection:为建立连接使用的编码方式
character_set_database:为数据库的编码方式
character_set_results:为结果集的编码
character_set_server:为数据库服务器的编码
#查看数据库信息
status
#查看数据库的所有用户信息
select distinct concat('user: ''',user,'''@''',host,''';') from mysql.user;
#查看某个具体用户的权限
show grants for 'root'@'localhost';
#查看数据库的最大连接数
show variables like '%max_connections%';
#查看当前数据库的连接数和并发数
show status like 'Threads%';
Threads_cached :当前此时此刻线程缓存中有多少空闲线程
Threads_connected :当前已建立连接的数量
Threads_created :从最近一次服务启动,已创建线程的数量
Threads_running :当前激活的线程数,并不是代表正在使用的线程数,有时候连接已建立,但是连接处于sleep状态,这里相对应的线程也是sleep状态。
#查看数据库某个表的信息
show create tables 表\G
show table status like '表' \G
#查看INNODB数据库引擎运行状态
show engine innodb status \G
#查看当前正在进行的进程
show processlist; 默认显示前100条
show full processlist; 显示所有
#查看当前已经被打开的表列表
show open tables;
【mysql简单设置】
最新推荐文章于 2024-07-18 20:04:15 发布