标签:
init_connect=‘set autocommit=0; set names gbk;‘
2.init_connect 来登记用户的信息:
mysql> create table t1 ( cur_user varchar(100), n_user varchar(100),in_time timestamp default current_timestamp()); Query OK, 0 rows affected (2.36 sec)
设定 init_connect :
set global init_connect=‘insert into test.t1 (cur_user,n_user) values (current_user(),user())‘;
普通用户登录: (root 用户无效)
[root@localhost uu]# mysql -umysql -p mysql> use test; 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> select * from t1; +------------+-----------------+---------------------+ | cur_user | n_user | in_time | +------------+-----------------+---------------------+ | @localhost | mysql@localhost | 2016-07-05 00:25:02 | +------------+-----------------+---------------------+ 1 row in set (0.07 sec)
注意: 对于所有的普通级别的用户,必须全部都要对日志表具有读写权限, 否则将导致,没有权限的用户无法使用数据库。
标签:
原文地址:http://www.cnblogs.com/zengkefu/p/5644107.html