http://blog.itpub.net/133735/viewspace-691196/
 

init_connect 是可以动态在线调整的,这样就有了一些其他的用处

经过测试init_connect 是用户登录到数据库上之后,在执行第一次查询之前执行 里面的内容的。 
 
如果init_connect  的内容有语法错误,导致执行失败,会导致用户无法执行查询,从mysql 退出。

init_connect 对具有super  权限的用户是无效的
 
 
1.设定字符集:

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)

注意: 对于所有的普通级别的用户,必须全部都要对日志表具有读写权限, 否则将导致,没有权限的用户无法使用数据库。

mysql init_connect 参数的其他用处的更多相关文章

  1. 【查阅】mysql配置文件/参数文件重要参数笔录(my.cnf)

    持续更新,积累自己对参数的理解 [1]my.cnf参数 [client]port = 3306socket = /mysql/data/3306/mysql.sockdefault-character ...

  2. 1201MySQL配置文件mysql.ini参数详解

    转自http://www.cnblogs.com/feichexia/archive/2012/11/27/mysqlconf.html my.ini(Linux系统下是my.cnf),当mysql服 ...

  3. (转)MySQL配置文件mysql.ini参数详解、MySQL性能优化

    本文转自:http://www.cr173.com/html/18331_1.html my.ini(Linux系统下是my.cnf),当mysql服务器启动时它会读取这个文件,设置相关的运行环境参数 ...

  4. MySQL配置文件mysql.ini参数详解、MySQL性能优化

    my.ini(Linux系统下是my.cnf),当mysql服务器启动时它会读取这个文件,设置相关的运行环境参数. my.ini分为两块:Client Section和Server Section.  ...

  5. MySQL配置文件mysql.ini参数详解

    my.ini(Linux系统下是my.cnf),当mysql服务器启动时它会读取这个文件,设置相关的运行环境参数. my.ini分为两块:Client Section和Server Section. ...

  6. 在Linux最大打开文件数限制下 MySQL 对参数的调整

    http://www.actionsky.com/docs/archives/78  2016年4月7日  周文雅 目录 1 起因 2 说明 3 MySQL调整参数的方式 3.1 计算 request ...

  7. skip-grant-tables:非常有用的mysql启动参数

    skip-grant-tables:非常有用的mysql启动参数   介绍一个非常有用的mysql启动参数—— --skip-grant-tables.顾名思义,就是在启动mysql时不启动grant ...

  8. MySql配置参数很全的Mysql配置参数说明

    MySql配置参数 很全的Mysql配置参数说明 1. back_log 指定MySQL可能的连接数量.当MySQL主线程在很短的时间内得到非常多的连接请求,该参数就起作用,之后主线程花些时间(尽管很 ...

  9. mysql dump 参数

    mysql dump 参数: -R, --routines Dump stored routines (functions and procedures). 备份 函数和存储过程: -E, --eve ...

随机推荐

  1. OpenSSH for Windows,CopSSH

    https://www.oschina.net/p/openssh+for+windows https://www.oschina.net/p/copssh

  2. Yorhom浅谈:作为一名初中生,自学编程的点点滴滴 - Yorhom's Game Box

    Yorhom浅谈:作为一名初中生,自学编程的点点滴滴 我是一名不折不扣的初中生,白天要背着书包去上学,晚上要拿起笔写作业.天天如此,年年如此. 我的爱好很广泛,喜欢了解历史,读侦探小说,骑车,打篮球, ...

  3. 【HDOJ】1027 Ignatius and the Princess II

    这道题目最开始完全不懂,后来百度了一下,原来是字典序.而且还是组合数学里的东西.看字典序的算法看了半天才搞清楚,自己仔细想了想,确实也是那么回事儿.对于长度为n的数组a,算法如下:(1)从右向左扫描, ...

  4. IPv6 tutorial 1 Get started now

    https://4sysops.com/archives/ipv6-part-1-get-started-now/ You’ve probably heard the news that the In ...

  5. Form - 遍历行

    go_block('block_name'); first_record; LOOP   message(:block_name.item);   if :system.last_record  = ...

  6. Redis 如何导出数据

    Redis是一款支持多种数据类型的Key-Value数据库. 这里介绍下如何从Redis中导出数据. 数据是如何存储的?. Redis中是把数据保存到内存中的,但是它也会定期的把数据写会到硬盘中. R ...

  7. HTMLPARSER.NET 参考资料

    例子1: using System;using System.IO;using Winista.Text.HtmlParser;using Winista.Text.HtmlParser.Lex;us ...

  8. C#线程篇---Task(任务)和线程池不得不说的秘密(5)

    在上篇最后一个例子之后,我们发现了怎么去使用线程池,调用ThreadPool的QueueUserWorkItem方法来发起一次异步的.计算限制的操作,例子很简单,不是吗? 然而,在今天这篇博客中,我们 ...

  9. Sending data to USB printer in C#?

    using System; using System.Drawing; using System.Drawing.Printing; using System.IO; using System.Run ...

  10. 016专家视图测试脚本开发- Environment对象的使用;Msgbox和Print的区别

    (1)读取Built-in 'file -> settings -> Enrionment -> variable type 为 Built-in os = Environment. ...