Home > Database > Mysql Tutorial > body text

How to check the ip address of mysql

PHPz
Release: 2020-09-27 10:33:17
Original
24830 people have browsed it

查看连接mysql的ip地址的方法:直接查询,语法为【select SUBSTRING_INDEX(host,':',1) as ip , count(*) from information_schema.processlist 】。

How to check the ip address of mysql

相关学习推荐:mysql数据库

查看连接mysql的ip地址的方法:

1、最直接的办法如下:

select SUBSTRING_INDEX(host,':',1) as ip , count(*) from information_schema.processlist group by ip;
Copy after login

2、要统计数据库的连接数,我们通常情况下是统计总数,没有细分到每个IP上。现在要监控每个IP的连接数,实现方式如下:

> select SUBSTRING_INDEX(host,':',1) as ip , count(*) from information_schema.processlist group by ip;
Copy after login

How to check the ip address of mysql

3、通过直接执行也可以实现:

#mysql -u root -h127.0.0.1 -e"show processlist\G;"| egrep "Host\:" | awk -F: '{ print $2 }'| sort | uniq -c 
#mysql -u root -h127.0.0.1 --skip-column-names -e"show processlist;"|awk '{print $3}'|awk -F":" '{print $1}'|sort|uniq –c
Copy after login

How to check the ip address of mysql

The above is the detailed content of How to check the ip address of mysql. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template