mysql查询统计连接情况

    xiaoxiao2026-10-04  0

    //哈哈,同事说滴,记录下。

    use test;

    CREATE TABLE if not exists  conn_log (   conn_id int(11) DEFAULT NULL,   conn_time datetime DEFAULT NULL,   user_name varchar(50) DEFAULT NULL,   cur_user_name varchar(50) DEFAULT NULL,   conn_date varchar(15) DEFAULT NULL,   KEY conn_time (conn_time) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

    set global init_connect="set @user=user(),@cur_user=current_user(); insert into test.conn_log values(connection_id(),now(),@user,@cur_user,CURDATE());";

    select * from   test.conn_log   //可以看到该示例有哪些ip在用root连过来 用完  set global init_connect="";

    PS: 短链接比较多 这个表会记录会比较多,慎用。

    相关资源:敏捷开发V1.0.pptx
    最新回复(0)