创建一个用于存放连接日记的数据和表.
creat database accesslog;
CREATE TABLE accesslog.accesslog(idint(11)primary key auto_increment,timetimestamp,localnamevarchar(30),matchnamevarchar(30));
创建用户权限.
grant select on accesslog.* to root;
注意用户必须对accesslog表具有insert权限.
grant select on accesslog.* to user@'%';
退出数据库或者重新开一个命令界面vi /etc /init.d /mysqld
注:在[mysqld]下添加以下这段话.
init-connect='insertinto accesslog.accesslog(id,time,localname,matchname)values(connection_id(),now(),user(),current_user());'
保存退出回到数据库.
select*from accesslog.accesslog where id= ;
show processlist;