解决方案就很直接了,设置正确的init_connect,就无需给新建用户授予super权限,都可以正常登录, set global init_connect ="set names utf8mb4"; 说起这个参数,可能有些DBA用它来做一些特殊的用途,例如对某些业务账号的限制等,所有非super权限账号都会执行一次,而具有super权限的账号或者DBA账号(通常有super的权限),...
解决方案就很直接了,设置正确的init_connect,就无需给新建用户授予super权限,都可以正常登录, set global init_connect = "set names utf8mb4"; 说起这个参数,可能有些DBA用它来做一些特殊的用途,例如对某些业务账号的限制等,所有非super权限账号都会执行一次,而具有super权限的账号或者DBA账号(通常有super的权限)...
setglobalinit_connect="insert into mysql.audit_login(USER,HOST,DB,PROCESSLIST_ID) values(current_user(),substring_index(user(),'@',-1),database(),connection_id());";-- my.cnf文件中的配置方法[mysqld] init_connect="insert into mysql.audit_login(USER,HOST,DB,PROCESSLIST_ID) values(curren...
SET GLOBAL init_connect='SET AUTOCOMMIT=0'; 还可以在命令行或选项文件中设置该变量。要想使用选项文件设置变量,应包括下述行: [mysqld] init_connect='SET AUTOCOMMIT=0' 请注意init_connect的内容并不为拥有SUPER权限的用户执行;实际是内容设置错误(包含错误查询,例如语法错误),这样使所有连接失败。不为SUPER用...
方案:init_connect + mysqlbinlog 步骤: 1. 建监控连接信息的表 代码语言:javascript 复制 use test; create table accesslog(`thread_id` int primary key, `time` timestamp, `localname` varchar(40), `machine_name` varchar(40)); 2. 设置变量 init_connect(不需要重启 MySQL 服务器) 代码语言:javas...
mysql> set global init_connect="set @user=user(),@cur_user=current_user();insert into test.conn_log values(connection_id(),now(),@user,@cur_user,'10.0.0.1');" -> ; Query OK, 0 rows affected (0.00 sec) mysql> show variables like '%init%'; ...
只能通过具有SUPER权限用户来修改init_connect的值。 如上环境中init_connect设置的值是'SET NAMES utf8mb4',如果我们直接执行这个指令,提示存在语法上的错误, 代码语言:sql 复制 >'SET NAMES utf8mb4';ERROR1064(42000): You have an errorinyourSQLsyntax;checkthe manual that correspondstoyour MySQL server...
set global init_connect='insert into auditlog.t_audit(id,thread_id,login_time,localname,matchname) values(null,connection_id(),now(),user(),current_user());'; 1. 1. 并在配置文件中增加如下语句: init-connect='insert into auditlog.t_audit(id,thread_id,login_time,localname,matchname) ...
mysql>set global init_connect='insert into db_monitor.accesslog(thread_id, log_time,localname,matchname) values(connection_id(),now(),user(),current_user());'; 在my.conf中添加 init_connect='insert into db_monitor.accesslog(thread_id, log_time,localname,matchname) values(connection_id(...