龙空技术网

zabbix 登录mysql常用命令

忆梦如风 108

前言:

现时朋友们对“mysql查看前十行”大体比较着重,兄弟们都需要知道一些“mysql查看前十行”的相关文章。那么小编同时在网上汇集了一些关于“mysql查看前十行””的相关知识,希望姐妹们能喜欢,小伙伴们快快来了解一下吧!

首先去看看mysql数据库

查看数据库

mysql> show databases;

+--------------------+

| Database |

+--------------------+

| zabbix |

+--------------------+

5 rows in set (0.00 sec)

进入数据库

mysql> use zabbix;

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Database changed

查看数据有那些表

mysql> show tables;

查看是否存放用户、密码信息

mysql> select * from users;

更改密码为zabbix

mysql> update users set passwd=md5("zabbix") where userid='1';

Query OK, 0 rows affected (0.01 sec)

Rows matched: 1 Changed: 0 Warnings: 0

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

1. 查看mysql 各数据库大小命令

SELECT table_schema "Database Name", sum( data_length + index_length ) / 1024 / 1024 "Database Size in MB" FROM information_schema.TABLES GROUP BY table_schema;

2. 查看zabbix数据库各表大小命令

SELECT table_name AS "Tables",round(((data_length + index_length) / 1024 / 1024), 2) "Size in MB" FROM information_schema.TABLES WHERE table_schema = "zabbix" ORDER BY (data_length + index_length) DESC;

3. 找出数据库中前十个最占用空间的表

SELECT CONCAT(table_schema, '.', table_name), CONCAT(ROUND(table_rows / 1000000, 2), 'M') rows, CONCAT(ROUND(data_length / ( 1024 * 1024 * 1024 ), 2), 'G') DATA, CONCAT(ROUND(index_length / ( 1024 * 1024 * 1024 ), 2), 'G') idx, CONCAT(ROUND(( data_length + index_length ) / ( 1024 * 1024 * 1024 ), 2), 'G') total_size, ROUND(index_length / data_length, 2) idxfrac FROM information_schema.TABLES ORDER BY data_length + index_length DESC LIMIT 10;

4. 清空表数据

uncate tablename;

创建zabbix数据库

create database zabbix character set utf8;

grant all on zabbix.* to 'zabbix'@'%' identified by '123456' with grant option;

flush privileges;

#允许账户zabbix能从本机连接到数据库zabbix#再次刷新系统授权表#进入数据库  注意:必须按顺序导入schema.sql à images.sql à data.sql[iyunv@node1 create]# mysql -uroot -p zabbix< schema.sql[iyunv@node1 create]# mysql -uroot -p zabbix< images.sql[iyunv@node1 create]# mysql -uroot -p zabbix< data.sql

关注点赞不迷路[可怜]

标签: #mysql查看前十行 #登录mysql的命令行是 #mysql登陆命令行 #mysql查询表的前十行