rootmysql
GRANTREVOKE
mysql -u rootroot
SHOW GRANTSREVOKE
SHA2()
nmapserver_host
内核> telnetserver_host3306
shell> tcpdump -l -i eth0 -w - src or dst port 3306 | strings
validate_password
.mylogin.cnf
-pyour_pass--password=your_pass
内核> mysql -u francis -pfrankdb_name
-p
shell> mysql -u francis -p db_name
Enter password: ********
*
[client]
[client] password=your_pass
400
shell> chmod 600 .my.cnf
--defaults-file=file_name
shell> mysql --defaults-file=/home/francis/mysql-opts
MYSQL_PWD
MYSQL_PWD
.mysql_historyCREATE USERALTER USER
~/.bash_history
mysql.user
validate_password
plugin_dir
CREATE USERGRANTSET PASSWORD
CREATE USER ... IDENTIFIED BY ... ALTER USER ... IDENTIFIED BY ... SET PASSWORD ... SLAVE START ... PASSWORD = ... CREATE SERVER ... OPTIONS(... PASSWORD ...) ALTER SERVER ... OPTIONS(... PASSWORD ...)
INSERTUPDATE
--log-raw
--log-raw
--log-raw
mysql
mysqlSTART
SLAVE
mysql -u other_user
db_nameother_user
rootFILE~root/.bashrcroot--user=root
mysqlusermy.cnf
[mysqld]user=mysql
rootuser
FILEFILESELECT ... INTO
OUTFILE
FILELOAD
DATASELECT
secure_file_priv
PROCESSSUPERSHOW
PROCESSLIST
CONNECTION_ADMINSUPER
SUPER
--skip-symbolic-linksroot
max_user_connectionsCREATE
USERALTER USER
SELECT
... INTO DUMPFILEplugin_dir--secure-file-privSELECT
mysql
tar.gzrootuser_name
user_name
shell> chown -R user_name /path/to/mysql/datadir
user_name
chown -R
user_nameroot--user=user_nameuser_name
user/etc/my.cnf
[mysqld]
user=user_name
root--user=root
LOAD DATA
LOCALLOAD
DATA
LOAD
DATALOAD DATA
LOCAL
LOAD DATA
LOCAL
LOAD DATA--ssl-mode=VERIFY_IDENTITY
LOCAL
local_infilelocal_infilelocal_infile
LOAD DATA
LOCALlocal_infilelocal_infile
ENABLED_LOCAL_INFILELOCALENABLED_LOCAL_INFILE
ENABLED_LOCAL_INFILEENABLED_LOCAL_INFILE
mysql_options()
--local-infile=0--local-infile[=1]
--local=0--local[=1]
LOAD
DATA LOCALlocal-infileloose-
[client]loose-local-infile=0
[client] loose-local-infile=1
LOCAL
LOCALLOAD DATA
LOCAL
错误1148:使用的命令是不允许使用这个版本的MySQL
; DROP DATABASE
mysql;
SELECT * FROM table WHERE ID=234234 OR 1=1SELECT * FROM table WHERE ID=234 OR 1=1SELECT * FROM table WHERE ID='234'
'
%22%23%27
mysql_real_escape_string_quote()
escape
mysqliext/mysql
ext/mysqlmysql_real_escape_string_quote()mysql_escape_string()mysql_real_escape_string_quote()
quote()
quote()
PreparedStatement
SELECTINSERTUPDATEDELETELOAD DATA
INFILE
CREATE USERGRANTREVOKE
mysql
joejoejoejoeSHOW GRANTS
显示“乔”'office补助。例如.com”;显示“乔”“返回”补助。例如.com”;
SELECTDROP
usertables_privprocs_privmysql
GRANTREVOKE
ALL [PRIVILEGES] | ||
ALTER | Alter_priv | |
ALTER ROUTINE | Alter_routine_priv | |
CREATE | Create_priv | |
CREATE ROLE | Create_role_priv | |
CREATE ROUTINE | Create_routine_priv | |
CREATE TABLESPACE | Create_tablespace_priv | |
CREATE TEMPORARY TABLES | Create_tmp_table_priv | |
CREATE USER | Create_user_priv | |
CREATE VIEW | Create_view_priv | |
DELETE | Delete_priv | |
DROP | Drop_priv | |
DROP ROLE | Drop_role_priv | |
EVENT | Event_priv | |
EXECUTE | Execute_priv | |
FILE | File_priv | |
GRANT OPTION | Grant_priv | |
INDEX | Index_priv | |
INSERT | Insert_priv | |
LOCK TABLES | Lock_tables_priv | |
PROCESS | Process_priv | |
PROXY | proxies_priv | |
REFERENCES | References_priv | |
RELOAD | Reload_priv | |
REPLICATION CLIENT | Repl_client_priv | |
REPLICATION SLAVE | Repl_slave_priv | |
SELECT | Select_priv | |
SHOW DATABASES | Show_db_priv | |
SHOW VIEW | Show_view_priv | |
SHUTDOWN | Shutdown_priv | |
SUPER | Super_priv | |
TRIGGER | Trigger_priv | |
UPDATE | Update_priv | |
USAGE |
GRANTREVOKE
AUDIT_ADMIN | |
BACKUP_ADMIN | |
BINLOG_ADMIN | |
CONNECTION_ADMIN | |
ENCRYPTION_KEY_ADMIN | |
FIREWALL_ADMIN | |
FIREWALL_USER | |
GROUP_REPLICATION_ADMIN | |
PERSIST_RO_VARIABLES_ADMIN | |
REPLICATION_SLAVE_ADMIN | |
RESOURCE_GROUP_ADMIN | |
RESOURCE_GROUP_USER | |
ROLE_ADMIN | |
SET_USER_ID | |
SYSTEM_VARIABLES_ADMIN | |
VERSION_TOKEN_ADMIN | |
XA_RECOVER_ADMIN |
FILE
FILESELECT
GRANT OPTIONGRANT OPTION
ALTER
SHUTDOWN
PROCESS
SUPER
mysqlauthentication_string
ALLALL
PRIVILEGESGRANT
OPTIONALL
ALTERALTER TABLEALTER TABLECREATEINSERTALTERDROPCREATEINSERT
ALTER ROUTINE
CREATE
CREATE ROLECREATE
ROLECREATE
USERCREATE ROLE
CREATE ROUTINE
CREATE TABLESPACE
CREATE TEMPORARY TABLESCREATE TEMPORARY TABLE
DROP TABLEINSERTUPDATESELECT
CREATE USERALTER
USERCREATE ROLECREATE USERDROP ROLEDROP USERRENAME USERREVOKE ALL
PRIVILEGES
CREATE VIEWCREATE
VIEW
DELETE
DROPDROPDROPTRUNCATE TABLEDROP
DROP ROLEDROP ROLECREATE USERDROP
ROLE
EVENT
EXECUTE
FILELOAD DATA
INFILESELECT ... INTO
OUTFILELOAD_FILE()FILEFILEFILEINDEX
DIRECTORYCREATE TABLE
secure_file_priv
GRANT OPTION
INDEXINDEXCREATECREATE TABLE
INSERTINSERTANALYZE TABLEOPTIMIZE TABLEREPAIR TABLE
LOCK TABLESLOCK
TABLESSELECT
PROCESSSHOW
PROCESSLISTPROCESSSHOW ENGINE
PROXY
REFERENCES
RELOADFLUSHFLUSHflush-logsflush-statusflush-threadsreload
reloadreloadflush-xxxflush-logs
REPLICATION CLIENTSHOW
MASTER STATUSSHOW SLAVE
STATUSSHOW BINARY
LOGS
REPLICATION SLAVE
SELECTSELECTSELECTSELECTSELECT
选择1 1;选择pi() *2;
SELECTSELECTcol_name=exprUPDATEDELETEUPDATE
SHOW DATABASES--skip-show-database
SHOW VIEWSHOW CREATE
VIEWEXPLAIN
SHUTDOWNSHUTDOWNRESTARTmysql_shutdown()
SUPER
SUPER
SUPERbinlog_formatsql_log_binsql_log_off
SYSTEM_VARIABLES_ADMIN
SYSTEM_VARIABLES_ADMIN
REPLICATION_SLAVE_ADMINGROUP_REPLICATION_ADMIN
CHANGE MASTER
TOCHANGE REPLICATION
FILTER
REPLICATION_SLAVE_ADMIN
PURGE BINARY LOGSBINLOG
BINLOG_ADMIN
DEFINER
SET_USER_ID
CREATE
SERVERALTER
SERVERDROP
SERVER
InnoDB
ENCRYPTION_KEY_ADMIN
VERSION_TOKEN_ADMIN
<graphml>ROLES_GRAPHML()
ROLE_ADMIN
SUPER
KILL
CONNECTION_ADMIN
SUPERmax_connections
CONNECTION_ADMIN
read_onlyGRANTREVOKE
CONNECTION_ADMIN
init_connectSUPER
CONNECTION_ADMIN
offline_modeSUPERSUPER
CONNECTION_ADMIN
SUPER
TRIGGER
INSERTUPDATEDELETETRIGGER
UPDATE
USAGEGRANTSHOW GRANTSUSAGE
AUDIT_ADMIN
BACKUP_ADMINLOCK INSTANCE FOR
BACKUPlog_status
BACKUP_ADMINRELOAD
BINLOG_ADMINPURGE
BINARY LOGSBINLOG
CONNECTION_ADMIN
CONNECTION_ADMIN
init_connectinit_connectCONNECTION_ADMIN
offline_modeoffline_modeCONNECTION_ADMINCONNECTION_ADMIN
read_onlyread_onlyGRANTREVOKE
ENCRYPTION_KEY_ADMIN
FIREWALL_ADMIN
FIREWALL_USER
GROUP_REPLICATION_ADMIN
PERSIST_RO_VARIABLES_ADMINSET
PERSIST_ONLYSET
PERSIST
REPLICATION_SLAVE_ADMINCHANGE MASTER TOCHANGE REPLICATION FILTER
RESOURCE_GROUP_ADMIN
RESOURCE_GROUP_USERSET
RESOURCE GROUP
ROLE_ADMINGRANT<graphml>ROLES_GRAPHML()
SET_USER_ID
SYSTEM_VARIABLES_ADMINSYSTEM_VARIABLES_ADMINbinlog_formatsql_log_binsql_log_off
VERSION_TOKEN_ADMIN
XA_RECOVER_ADMINXA
RECOVER
XA
RECOVERXA
RECOVERXA_RECOVER_ADMIN
SELECTINSERT
INSTALL COMPONENT 'my_component'; UNINSTALL COMPONENT 'my_component'; INSTALL COMPONENT 'my_component';
INSTALL COMPONENTUNINSTALL COMPONENTINSTALL
COMPONENT
mysql.global_grants
global_grants--skip-grant-tables
global_grants
u1
Grant repedicience at the Suse Per AMIN,Group Const Relipped Per AMIN,BINOLG ET ADMinon * . * to ' u1 ' @encipast;
SHOW GRANTSUSER_PRIVILEGES
GRANTREVOKE
GRANTREVOKE
GRANT ALL
REVOKE ALL
FLUSH PRIVILEGES
SUPERSUPERSUPERSUPER
SUPERSUPERSUPERSUPER
SUPER
SELECT GRANTEE FROM INFORMATION_SCHEMA.USER_PRIVILEGESWHERE PRIVILEGE_TYPE = 'SUPER';
SUPERSUPER
'u1'@'localhost'SUPER
格兰特binlog_admin,system_variables_admin *。*“U1 '@'本地主机';撤销超*。*从U1 '@'本地主机';
INFORMATION_SCHEMA
mysql
CREATE USERGRANTREVOKE
INSERTUPDATEDELETE
mysql
user
global_grants
db
tables_priv
columns_priv
procs_priv
proxies_priv
default_roles
role_edges
password_history
InnoDBCREATE
USERGRANT
userUser'bob'bobHostDb'bob'bobreportscolumns_priv
user
SHOW
DATABASESSCHEMATA
global_grants
db
tables_privdb
procs_priv
proxies_privPROXY
default_roles
password_history
usermysqluser
user | db | |
|---|---|---|
Host | Host | |
User | Db | |
User | ||
Select_priv | Select_priv | |
Insert_priv | Insert_priv | |
Update_priv | Update_priv | |
Delete_priv | Delete_priv | |
Index_priv | Index_priv | |
Alter_priv | Alter_priv | |
Create_priv | Create_priv | |
Drop_priv | Drop_priv | |
Grant_priv | Grant_priv | |
Create_view_priv | Create_view_priv | |
Show_view_priv | Show_view_priv | |
Create_routine_priv | Create_routine_priv | |
Alter_routine_priv | Alter_routine_priv | |
Execute_priv | Execute_priv | |
Trigger_priv | Trigger_priv | |
Event_priv | Event_priv | |
Create_tmp_table_priv | Create_tmp_table_priv | |
Lock_tables_priv | Lock_tables_priv | |
References_priv | References_priv | |
Reload_priv | ||
Shutdown_priv | ||
Process_priv | ||
File_priv | ||
Show_db_priv | ||
Super_priv | ||
Repl_slave_priv | ||
Repl_client_priv | ||
Create_user_priv | ||
Create_tablespace_priv | ||
Create_role_priv | ||
Drop_role_priv | ||
ssl_type | ||
ssl_cipher | ||
x509_issuer | ||
x509_subject | ||
plugin | ||
authentication_string | ||
password_expired | ||
password_last_changed | ||
password_lifetime | ||
account_locked | ||
Password_reuse_history | ||
Password_reuse_time | ||
Password_require_current | ||
max_questions | ||
max_updates | ||
max_connections | ||
max_user_connections |
userauthentication_string
plugin
pluginFLUSH
PRIVILEGESplugin
[警告]用户入口” user_name“@” host_name“有一个空的pluginvalue。用户将被忽略,没有人可以用这useranymore登录。
password_expired'N'ALTER USERALTER USER
password_last_changedNULLsha256_passwordNULL
password_last_changedCREATE USERALTER USERSET PASSWORDGRANT
password_lifetimeNNdefault_password_lifetime
account_locked
Password_reuse_historyNULL
Password_reuse_timeNULL
Password_require_current
'Y' | PASSWORD REQUIRE CURRENT |
'N' | PASSWORD REQUIRE CURRENT OPTIONAL |
NULL | PASSWORD REQUIRE CURRENT DEFAULT |
usertables_priv
tables_priv | columns_priv | |
|---|---|---|
Host | Host | |
Db | Db | |
User | User | |
Table_name | Table_name | |
Column_name | ||
Table_priv | Column_priv | |
Column_priv | ||
Timestamp | Timestamp | |
Grantor |
TimestampCURRENT_USER
procs_priv
Routine_typeENUM'PROCEDURE'
Timestamp
proxies_priv
PROXYWith_grantProxied_userproxies_privPROXYroot
global_grants
USER
PRIV
WITH_GRANT_OPTION
default_roles
HOST
DEFAULT_ROLE_HOST
role_edges
FROM_HOST
TO_HOST
WITH_ADMIN_OPTION
password_history
Host
Password_timestamp
Password
password_history
Host | |
User | |
Db | |
Table_name | |
Column_name | |
Routine_name |
Userauthentication_stringTable_nameProxied_hostRoutine_name
userENUM('N','Y') DEFAULT 'N'
tables_privprocs_privSET
tables_priv | Table_priv | 'Select', 'Insert', 'Update', 'Delete', 'Create', 'Drop',
'Grant', 'References', 'Index', 'Alter', 'Create View',
'Show view', 'Trigger' |
tables_priv | Column_priv | 'Select', 'Insert', 'Update', 'References' |
columns_priv | Column_priv | 'Select', 'Insert', 'Update', 'References' |
procs_priv | Proc_priv | 'Execute', 'Alter Routine', 'Grant' |
userRELOADSHUTDOWN
FILE
FLUSH PRIVILEGES
SHOW GRANTSpc84.example.com
显示“鲍勃”'pc84补助。例如.com”;
SHOW CREATE USER
显示创建用户“鲍勃”'pc84。例如.com”;
CREATE
USERGRANTSET PASSWORD
'user_name'@'host_name'
'user_name'@'%''me'@'%'
user_namehost_name%
`"
'me'@'localhost''me@localhost'@'%'
CURRENT_USERCURRENT_USER()
mysql
''@'localhost'
'localhost''::1'
%LIKE'%.mysql.com''198.51.100.%'
'198.51.100.%'1.2.example.com
host_ip/netmask
创建用户“戴维”'198.51.100.0 / 255.255.255.0”;
davidclient_ip
client_ip& netmask=host_ip
CREATE USER
client_ip& 255.255.255.0 = 198.51.100.0198.51.100.0
198.0.0.0/255.0.0.0
198.51.100.0/255.255.0.0
198.51.100.0/255.255.255.0
198.51.100.1
host1.example.comhost1
198.51.100.2198.051.100.2198.051.100.%
'%''%''%'
CURRENT_USER()
mysql.user
SET ROLE 'myrole'@'%';
'myrole'@'%'
'%'
userUseruserHostuser'N'UserALTER USER
Useruser
authentication_string
authentication_string
mysql
Useruser
User | Host | |
|---|---|---|
'fred' | 'h1.example.net' | fred |
'' | 'h1.example.net' | h1.example.net |
'fred' | '%' | fred |
'' | '%' | |
'fred' | '%.example.net' | fred |
'fred' | 'x.example.%' | fredx.example.com |
'fred' | '198.51.100.177' | fred |
'fred' | '198.51.100.%' | fred |
'fred' | '198.51.100.0/255.255.255.0' |
userfred
user
Host198.51.100.0/255.255.255.0'''%'UserHost
user
----------- ---------- - |主机|用户|…----------- ---------- - | % |根|…| % |杰夫瑞|…| localhost |根|…| localhost | |…----------- ----------—
+-----------+----------+- | Host | User | ... +-----------+----------+- | localhost | root | ... | localhost | | ... | % | jeffrey | ... | % | root | ... +-----------+----------+-
localhostHost'localhost''%''localhost'
user
---------------- ---------- - |主机|用户|…---------------- ---------- - | % |杰夫瑞|…| h1.example.net | |…---------------- ----------—
+----------------+----------+- | Host | User | ... +----------------+----------+- | h1.example.net | | ... | % | jeffrey | ... +----------------+----------+-
jeffreyjeffrey
h1.example.net'jeffrey'jeffrey
CURRENT_USER()user_name@host_nameHostjeffrey
MySQL的> SELECT CURRENT_USER();---------------- | current_user() | ---------------- | @本地| ----------------
userjeffrey
user
usertables_privprocs_priv
userDELETEuser
db
dbdbDbuser
tables_privprocs_priv
%HostLIKE
'%'
DbColumn_name
tables_privprocs_privDbdb
SHUTDOWNRELOADuserSHUTDOWNShutdown_priv
INSERTUPDATEuser
dbDbHostDbUser
dbtables_privprocs_privcolumns_priv
global privileges OR (database privileges AND host privileges) OR table privileges OR column privileges OR routine privileges
userINSERT INTO ...
SELECTINSERTSELECTdb
GRANTREVOKESET
PASSWORDRENAME USER
INSERTUPDATEDELETE
FLUSH PRIVILEGES
USE
db_name
--skip-grant-tables
shell>mysqlERROR 2003: Can't connect to MySQL server on 'host_name' (111) shell>mysqlERROR 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (111)
--port--socket
内核> netstat -ln | grep mysql
--skip-networking--bind-address=127.0.0.1
mysql
mysqlvarmysql
root
内核> mysql -u root错误1045(28000):拒绝访问用户的根'@'本地主机'(使用密码:无)
root--password-p
内核> mysql -u root -p输入密码:
rootroot
shell> mysql
Client does not support authentication protocol requested
by server; consider upgrading MySQL client
Access
denied
--no-defaults
内核> mysqladmin --no-defaults -u root version
root
内核> mysqladmin -u root -pxxxxver用户访问被拒绝的根'@'本地主机'(使用密码:是的)
--no-defaults
root
localhost
--host=127.0.0.1--host
Access deniedusing password: NO
Access denieduser_namemysql -u root mysql
SELECT * FROM用户;
Host
user
Host ... is not allowed to connect to this MySQL server
'%'user'%'
glibc
shell> mysqladmin -u root -pxxxx -h some_hostname ver
Access denied for user 'root'@'' (using password: YES)
rootUser
Access denied for user ''@'unknown'
/etc/hosts
localhost
.
mysql -u rootyour_hostnameyour_hostnameHost'pluto''pluto.example.com'HostHostHost
mysql -u
user_nameuser_namesome_dbsome_db
mysql -u
user_namehost_nameuser_name
Access
deniedHost'_'='%'='some_user'Host=User=Host'%'Host=User=some_user='localhost'=''FLUSH
PRIVILEGES
Access deniedSELECT ... INTO
OUTFILELOAD DATA
INFILEFILE
INSERTUPDATEDELETEFLUSH PRIVILEGESrootUPDATE
mysql -u
user_name
db_nameuser_nameyour_passdb_name-p--password=your_pass--password
--skip-grant-tablesSHOW GRANTS
--debug=d,general,query
--skip-grant-tables
useruser
-u
mysql
mysql
mysql_native_password
user
user
mysql_options()
--default-character-setmysql_options()mysql_options()
ucs2utf32
rootCREATE USERDROP USERGRANTREVOKE
shell> mysql --user=finley --password db_name
shell> mysql -u finley -p db_name
--password
shell>mysql --user=finley --password=shell>passworddb_namemysql -u finley -ppassworddb_name
-p-p
CREATE USERGRANT
INSERTUPDATEDELETE
phpMyAdmin
rootCREATE USER
root
内核> mysql --user=root mysql
root-p
rootCREATE USER GRANT
MySQL的> CREATE USER 'finley'@'localhost' IDENTIFIED BY 'password';MySQL的> GRANT ALL PRIVILEGES ON *.* TO 'finley'@'localhost'-> WITH GRANT OPTION;MySQL的> CREATE USER 'finley'@'%' IDENTIFIED BY 'password';MySQL的> GRANT ALL PRIVILEGES ON *.* TO 'finley'@'%'-> WITH GRANT OPTION;MySQL的> CREATE USER 'admin'@'localhost' IDENTIFIED BY 'password';MySQL的> GRANT RELOAD,PROCESS ON *.* TO 'admin'@'localhost';MySQL的> CREATE USER 'dummy'@'localhost';
finley'finley'@'%'
'finley'@'localhost''finley'@'localhost'finley'finley'@'%'user
'admin'@'localhost'RELOADPROCESSxxxGRANT
'dummy'@'localhost'GRANT
SHOW GRANTS
MySQL的> SHOW GRANTS FOR 'admin'@'localhost';----------------------------------------------------- |授予管理员@本地| ----------------------------------------------------- |格兰特重装,过程*。*“admin '@'本地主机' | -----------------------------------------------------
SHOW CREATE USER
MySQL的> SHOW CREATE USER 'admin'@'localhost'\G*************************** 1。行***************************创建管理员@本地用户:创建用户Admin @ 'localhost'identified ' mysql_native_password'as * 67acdebdab923990001f0ffb017eb8ed41861105'require没有到期默认帐户解锁密码
custompassword
MySQL的> CREATE USER 'custom'@'localhost' IDENTIFIED BY 'password';MySQL的> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP-> ON bankaccount.*-> TO 'custom'@'localhost';MySQL的> CREATE USER 'custom'@'host47.example.com' IDENTIFIED BY 'password';MySQL的> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP-> ON expenses.*-> TO 'custom'@'host47.example.com';MySQL的> CREATE USER 'custom'@'%.example.com' IDENTIFIED BY 'password';MySQL的> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP-> ON customer.*-> TO 'custom'@'%.example.com';
bankaccount
expenses
customer%
CREATE ROLEDROP ROLE
SHOW GRANTS
SET DEFAULT ROLE
SET ROLE
CURRENT_ROLE()
mandatory_rolesactivate_all_roles_on_login
root
app_db
CREATE
ROLE
创建角色的app_developer ',' app_read ',' app_write”;
'user_name'@'host_name'-
GRANT
给予所有对app_db。*“app_developer”;授予选择app_db。*“app_read’;格兰特插入,更新,删除app_db。*“app_write”;
CREATE USER
创建用户“Dev1 '@'本地主机'确定' dev1pass”;创建用户read_user1 '@'本地主机'确定' read_user1pass”;创建用户read_user2 '@'本地主机'确定' read_user2pass”;创建用户rw_user1 '@'本地主机'确定' rw_user1pass”;
GRANTGRANT
格兰特app_developer”到“Dev1 '@'本地主机';格兰特app_read '到' read_user1 '@'本地主机',' read_user2 '@'本地主机';格兰特app_read ',' app_write '到' rw_user1 '@'本地主机';
GRANT
GRANTONGRANT
mandatory_roles
mandatory_roles
[mysqld] mandatory_roles='role1,role2@localhost,r3@%.example.com'
mandatory_roles
SET PERSIST mandatory_roles = 'role1,role2@localhost,r3@%.example.com';
SET
PERSISTGLOBAL
mandatory_rolesROLE_ADMINSYSTEM_VARIABLES_ADMINSUPER
activate_all_roles_on_loginSET
ROLE
mandatory_rolesREVOKEDROP ROLEDROP USER
mandatory_rolesFLUSH
PRIVILEGES
SHOW GRANTS
SHOW GRANTS
MySQL的> SHOW GRANTS FOR 'dev1'@'localhost';------------------------------------------------- |补助金”dev1 | ------------------------------------------------- |格兰特使用localhost创造*。* ` ` ` `”dev1本地应用程序开发者| |格兰特”_ ` ` ` ` `分` dev1 to“localhost”| -------------------------------------------------
USING
MySQL的> SHOW GRANTS FOR 'dev1'@'localhost' USING 'app_developer';---------------------------------------------------------- |补助Dev1 @本地| ---------------------------------------------------------- |授予使用*。* ` Dev1 ` @ ` localhost ` | |赋予全部权限` app_db `。* ` Dev1 ` @ ` localhost ` | |格兰特` app_developer ` @ ` % `到` Dev1 ` @ ` localhost ` | ----------------------------------------------------------
mysql>SHOW GRANTS FOR 'read_user1'@'localhost' USING 'app_read';+--------------------------------------------------------+ | Grants for read_user1@localhost | +--------------------------------------------------------+ | GRANT USAGE ON *.* TO `read_user1`@`localhost` | | GRANT SELECT ON `app_db`.* TO `read_user1`@`localhost` | | GRANT `app_read`@`%` TO `read_user1`@`localhost` | +--------------------------------------------------------+ mysql>SHOW GRANTS FOR 'rw_user1'@'localhost' USING 'app_read', 'app_write';+------------------------------------------------------------------------------+ | Grants for rw_user1@localhost | +------------------------------------------------------------------------------+ | GRANT USAGE ON *.* TO `rw_user1`@`localhost` | | GRANT SELECT, INSERT, UPDATE, DELETE ON `app_db`.* TO `rw_user1`@`localhost` | | GRANT `app_read`@`%`,`app_write`@`%` TO `rw_user1`@`localhost` | +------------------------------------------------------------------------------+
SHOW GRANTS
CURRENT_ROLE()
mandatory_rolesrw_user1CURRENT_ROLE()
mysql> SELECT CURRENT_ROLE();
+----------------+
| CURRENT_ROLE() |
+----------------+
| NONE |
+----------------+
SET DEFAULT ROLE
设置默认的角色dev1 all to“localhost”“@”,“@”读_ user1 localhost”、“读“@”_ user2 RW _ user1 localhost”、“localhost”“@”;
rw_user1CURRENT_ROLE()
MySQL的> SELECT CURRENT_ROLE();-------------------------------- | current_role() | -------------------------------- | ` app_read ` @ ` % `,` app_write ` @ ` % ` | --------------------------------
activate_all_roles_on_login
SET
ROLE
mysql>SET ROLE NONE; SELECT CURRENT_ROLE();+----------------+ | CURRENT_ROLE() | +----------------+ | NONE | +----------------+ mysql>SET ROLE ALL EXCEPT 'app_write'; SELECT CURRENT_ROLE();+----------------+ | CURRENT_ROLE() | +----------------+ | `app_read`@`%` | +----------------+ mysql>SET ROLE DEFAULT; SELECT CURRENT_ROLE();+--------------------------------+ | CURRENT_ROLE() | +--------------------------------+ | `app_read`@`%`,`app_write`@`%` | +--------------------------------+
SET ROLE
DEFINER
DEFINERactivate_all_roles_on_loginSET ROLE
REVOKEroleFROMuser;
mandatory_roles
REVOKEREVOKE
REVOKE INSERT, UPDATE, DELETE ON app_db.* FROM 'app_write';
SHOW GRANTS
MySQL的> SHOW GRANTS FOR 'app_write';--------------------------------------- |补助app_write @ % | --------------------------------------- |授予使用*。* ` app_write ` @ ` % ` | ---------------------------------------
rw_user1INSERTUPDATEDELETE
MySQL的> SHOW GRANTS FOR 'rw_user1'@'localhost'USING 'app_read', 'app_write';---------------------------------------------------------------- |补助rw_user1 @本地| ---------------------------------------------------------------- |授予使用*。* ` rw_user1 ` @ ` localhost ` | |格兰特选择` app_db `。* ` rw_user1 ` @ ` localhost ` | |格兰特` app_read ` @ ` % `,` app_write ` @ ` % `到` rw_user1 `“` localhost ` | ----------------------------------------------------------------
rw_user1
GRANT INSERT, UPDATE, DELETE ON app_db.* TO 'app_write';
rw_user1
DROP ROLE
删除角色的app_read ',' app_write”;
mandatory_roles
SHOW
GRANTS
CREATE USER 'u1'; CREATE ROLE 'r1'; GRANT SELECT ON db1.* TO 'u1'; GRANT SELECT ON db2.* TO 'r1'; CREATE USER 'u2'; CREATE ROLE 'r2'; GRANT 'u1', 'r1' TO 'u2'; GRANT 'u1', 'r1' TO 'r2';
u2u1
mysql>SHOW GRANTS FOR 'u2' USING 'u1', 'r1';+-------------------------------------+ | Grants for u2@% | +-------------------------------------+ | GRANT USAGE ON *.* TO `u2`@`%` | | GRANT SELECT ON `db1`.* TO `u2`@`%` | | GRANT SELECT ON `db2`.* TO `u2`@`%` | | GRANT `u1`@`%`,`r1`@`%` TO `u2`@`%` | +-------------------------------------+ mysql>SHOW GRANTS FOR 'r2' USING 'u1', 'r1';+-------------------------------------+ | Grants for r2@% | +-------------------------------------+ | GRANT USAGE ON *.* TO `r2`@`%` | | GRANT SELECT ON `db1`.* TO `r2`@`%` | | GRANT SELECT ON `db2`.* TO `r2`@`%` | | GRANT `u1`@`%`,`r1`@`%` TO `r2`@`%` | +-------------------------------------+
CREATE USER 'old_app_dev'@'localhost' IDENTIFIED BY 'old_app_devpass'; GRANT ALL ON old_app.* TO 'old_app_dev'@'localhost';
ALTER USER 'old_app_dev'@'localhost' IDENTIFIED BY 'new_password';
ALTER USER 'old_app_dev'@'localhost' ACCOUNT LOCK;
CREATE USER 'new_app_dev1'@'localhost' IDENTIFIED BY 'new_password'; GRANT 'old_app_dev'@'localhost' TO 'new_app_dev1'@'localhost';
'root'@'localhost
root
'mysql.sys'@'localhost'sysroot
'mysql.session'@'localhost'
'mysql.infoschema'@'localhost'INFORMATION_SCHEMA
max_user_connectionsmax_user_connections
mysql.userHost'usera'@'%.example.com'Useruserauserausera
--old-style-user-limitshost1.example.comusera
CREATE USERALTER USERcustomer
MySQL的> CREATE USER 'francis'@'localhost' IDENTIFIED BY 'frank'-> WITH MAX_QUERIES_PER_HOUR 20-> MAX_UPDATES_PER_HOUR 10-> MAX_CONNECTIONS_PER_HOUR 5-> MAX_USER_CONNECTIONS 2;
WITHmax_user_connectionsmax_user_connections
ALTER USER
mysql> ALTER USER 'francis'@'localhost' WITH MAX_QUERIES_PER_HOUR 100;
francis
MySQL的> ALTER USER 'francis'@'localhost' WITH MAX_CONNECTIONS_PER_HOUR 0;
MAX_USER_CONNECTIONSmax_user_connectionsmax_user_connections
对话框,使用最大值的用户,用户的用户的连接,使用最大的用户,用户的用户的连接,使用最大的用户,用户的用户,用户的用户的连接。
user1max_user_connectionsuser2MAX_USER_CONNECTIONS
usermax_updatesmax_user_connections
FLUSH USER_RESOURCESFLUSH
PRIVILEGES
MAX_USER_CONNECTIONS
MAX_USER_CONNECTIONSER_TOO_MANY_USER_CONNECTIONSER_USER_LIMIT_REACHED
userCREATE USERINSERTUPDATEread_onlyCREATE USERALTER USERCONNECTION_ADMINSUPER
mysql.userCREATE
USERALTER USER
CREATE USER
CREATE USER 'jeffrey'@'localhost' IDENTIFIED BY 'password';
CREATE USER
ALTER USER
ALTER USER 'jeffrey'@'localhost' IDENTIFIED BY 'password';
ALTER USER USER() IDENTIFIED BY 'password';
mysqladmin -uuser_name-hhost_namepassword "password"
mysql.useruser_nameHost
CHANGE MASTER TO
validate_password
mysql
[错误] mysql.user列计数错误。expected49,发现47。表可能损坏[警告] ACL表mysql.password_history失踪的一些操作可能失败。
mysql.usersha256_password
ALTER USER
修改用户密码”(localhost,呼气;
mysql.user
mysql.user
default_password_lifetimedefault_password_lifetimeNN
my.cnf
[mysqld]default_password_lifetime=180
default_password_lifetime
[mysqld]default_password_lifetime=0
default_password_lifetime
SET PERSIST default_password_lifetime = 180;SET PERSIST default_password_lifetime = 0;
SET
PERSISTGLOBAL
PASSWORD EXPIRECREATE USERALTER USER
CREATE USER 'jeffrey'@'localhost' PASSWORD EXPIRE INTERVAL 90 DAY; ALTER USER 'jeffrey'@'localhost' PASSWORD EXPIRE INTERVAL 90 DAY;
CREATE USER 'jeffrey'@'localhost' PASSWORD EXPIRE NEVER; ALTER USER 'jeffrey'@'localhost' PASSWORD EXPIRE NEVER;
CREATE USER 'jeffrey'@'localhost' PASSWORD EXPIRE DEFAULT; ALTER USER 'jeffrey'@'localhost' PASSWORD EXPIRE DEFAULT;
mysql>SELECT 1;ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement. mysql>ALTER USER USER() IDENTIFIED BY 'Query OK, 0 rows affected (0.01 sec) mysql>password';SELECT 1;+---+ | 1 | +---+ | 1 | +---+ 1 row in set (0.00 sec)
password_historypassword_reuse_interval
my.cnf
[mysqld]password_history=6password_reuse_interval=365
SET PERSIST password_history = 6; SET PERSIST password_reuse_interval = 365;
SET
PERSISTGLOBAL
PASSWORD HISTORYCREATE USERALTER USER
CREATE USER 'jeffrey'@'localhost' PASSWORD HISTORY 5; ALTER USER 'jeffrey'@'localhost' PASSWORD HISTORY 5;
CREATE USER 'jeffrey'@'localhost' PASSWORD REUSE INTERVAL 365 DAY; ALTER USER 'jeffrey'@'localhost' PASSWORD REUSE INTERVAL 365 DAY;
PASSWORD HISTORY
CREATE USER 'jeffrey'@'localhost' PASSWORD HISTORY 5 PASSWORD REUSE INTERVAL 365 DAY; ALTER USER 'jeffrey'@'localhost' PASSWORD HISTORY 5 PASSWORD REUSE INTERVAL 365 DAY;
CREATE USER 'jeffrey'@'localhost' PASSWORD HISTORY DEFAULT PASSWORD REUSE INTERVAL DEFAULT; ALTER USER 'jeffrey'@'localhost' PASSWORD HISTORY DEFAULT PASSWORD REUSE INTERVAL DEFAULT;
mysql.userCREATE
USERALTER USER
PASSWORD REQUIRE
CURRENT
PASSWORD REQUIRE CURRENT
OPTIONAL
PASSWORD REQUIRE CURRENT
DEFAULTpassword_require_current
password_require_current
password_require_current
PASSWORD
REQUIRE CURRENT DEFAULTpassword_require_currentpassword_require_current
password_require_currentPASSWORD REQUIRE
CURRENT DEFAULT
password_require_current
PASSWORD REQUIRE CURRENT | OFF | |
PASSWORD REQUIRE CURRENT | ON | |
PASSWORD REQUIRE CURRENT OPTIONAL | OFF | |
PASSWORD REQUIRE CURRENT OPTIONAL | ON | |
PASSWORD REQUIRE CURRENT DEFAULT | OFF | |
PASSWORD REQUIRE CURRENT DEFAULT | ON |
CREATE USERUPDATE
password_require_current
my.cnf
[mysqld]password_require_current=ON
password_require_current
SET PERSIST password_require_current = ON;SET PERSIST password_require_current = OFF;
SET
PERSISTGLOBAL
PASSWORD
REQUIRECREATE
USERALTER USER
CREATE USER 'jeffrey'@'localhost' PASSWORD REQUIRE CURRENT; ALTER USER 'jeffrey'@'localhost' PASSWORD REQUIRE CURRENT;
CREATE USER 'jeffrey'@'localhost' PASSWORD REQUIRE CURRENT OPTIONAL; ALTER USER 'jeffrey'@'localhost' PASSWORD REQUIRE CURRENT OPTIONAL;
CREATE USER 'jeffrey'@'localhost' PASSWORD REQUIRE CURRENT DEFAULT; ALTER USER 'jeffrey'@'localhost' PASSWORD REQUIRE CURRENT DEFAULT;
ALTER
USERSET PASSWORDALTER
USERSET
PASSWORD
REPLACE
ALTER USER USER() IDENTIFIED BY 'auth_string' REPLACE 'current_auth_string';
ALTER USER 'jeffrey'@'localhost' IDENTIFIED BY 'auth_string' REPLACE 'current_auth_string';
ALTER USER 'jeffrey'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'auth_string' REPLACE 'current_auth_string';
REPLACE
REPLACE
REPLACE
REPLACE
REPLACEjeffrey
REPLACE
ER_MUST_CHANGE_PASSWORD_LOGIN
内核> mysql -u myuser -p密码 ******错误1862(hy000):您的密码已过期。登录你要改变它使用支持过期密码的客户。
ALTER USERSET PASSWORD
SET
ER_MUST_CHANGE_PASSWORD
MySQL的> USE performance_schema;错误1820(hy000):你必须重置您的密码使用ALTER userstatement执行该语句之前。MySQL > SELECT 1;错误1820(hy000):你必须重置您的密码使用ALTER userstatement执行此语句之前。
--connect-expired-password
MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDSmysql_options()
arg = 1;result = mysql_options(mysql, MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS, &arg);
MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS--connect-expired-password
CLIENT_CAN_HANDLE_EXPIRED_PASSWORDSmysql_real_connect()
mysql = mysql_real_connect(mysql, host, user, password, db, port, unix_socket, CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS);
disconnect_on_expired_password
disconnect_on_expired_passwordER_MUST_CHANGE_PASSWORD_LOGIN
disconnect_on_expired_password
mysql.user
mysql.user
--skip-grant-tables--skip-grant-tables--skip-networking
mysql_native_password
default_authentication_plugin
--default-auth=plugin_name
--plugin-dir=dir_name
caching_sha2_password
sha256_password
mysql_old_password--secure-auth=0
libmysqlclient
libmysqlclientMYSQL_DEFAULT_AUTHmysql_options()
caching_sha2_passwordMYSQL_DEFAULT_AUTH
CREATE
USERALTER
USER
CREATE USERGRANT
PROXY
-- create proxy account CREATE USER 'employee_ext'@'localhost' IDENTIFIED WITH my_auth_plugin AS 'my_auth_string'; -- create proxied account and grant its privileges CREATE USER 'employee'@'localhost' IDENTIFIED BY 'employee_pass'; GRANT ALL ON employees.* TO 'employee'@'localhost'; -- grant PROXY privilege to proxy account for proxied account GRANT PROXY ON 'employee'@'localhost' TO 'employee_ext'@'localhost';
employee_extmy_auth_plugin'my_auth_string'employee_extemployee_ext
employee_ext
employeeemployee_extPROXYemployee_extemployee_extemployee_ext
USER()CURRENT_USER()
MySQL的> SELECT USER(), CURRENT_USER();------------------------ -------------------- | user() | current_user() | ------------------------ -------------------- | employee_ext @本地|员工@本地| ------------------------ --------------------
CREATE USERAS
'auth_string'
PROXYGRANT
授权代理” proxied_user' ' proxy_user';
mysql.proxies_priv
proxy_userproxied_user
REVOKE
撤销代理” proxied_user“从” proxy_user';
格兰特'a'到B的代理,C,D;格兰特'a'到D的权限授予代理;代理“”“”“”;撤销'从' B '代理,C,D;
PROXY
GRANT PROXY ... WITH GRANT
OPTIONproxied_user
proxied_userUSER()CURRENT_USER()proxied_user
rootPROXY ... WITH GRANT
OPTIONroot
CREATE USER 'admin'@'localhost' IDENTIFIED BY 'test'; GRANT PROXY ON ''@'' TO 'admin'@'localhost' WITH GRANT OPTION;
adminadmin
Grant Proxy Proxy on Sally to Joe;
''@''
-- create default proxy account CREATE USER ''@'' IDENTIFIED WITH ldap_auth AS 'O=Oracle, OU=MySQL'; -- create proxied accounts CREATE USER 'developer'@'localhost' IDENTIFIED BY 'developer_pass'; CREATE USER 'manager'@'localhost' IDENTIFIED BY 'manager_pass'; -- grant PROXY privilege to default proxy account for proxied accounts GRANT PROXY ON 'manager'@'localhost' TO ''@''; GRANT PROXY ON 'developer'@'localhost' TO ''@'';
shell>mysql --user=myuser --password ...Enter password:myuser_pass
myuserldap_authmyuser_pass
ldap_authmyuser
ldap_authdevelopermyuser''@''PROXYdeveloperUSER()CURRENT_USER()
MySQL的> SELECT USER(), CURRENT_USER();------------------ --------------------- | user() | current_user() | ------------------ --------------------- |中@本地|开发者@本地| ------------------ ---------------------
myusermyuser
mysql> SELECT USER(), CURRENT_USER();
+------------------+-------------------+
| USER() | CURRENT_USER() |
+------------------+-------------------+
| myuser@localhost | manager@localhost |
+------------------+-------------------+
developerdeveloper
'''%'
-- create default proxy account CREATE USER ''@'' IDENTIFIED WITH some_plugin AS 'some_auth_string'; -- create anonymous account CREATE USER ''@'%' IDENTIFIED BY 'some_password';
''@''
''''''@''
localhost
CREATE USER ''@'localhost' IDENTIFIED WITH some_plugin AS 'some_auth_string';
GRANT PROXY''@''
localhost
-- create proxy user for local connections CREATE USER ''@'localhost' IDENTIFIED WITH some_plugin AS 'some_auth_string'; -- create proxy user for remote connections CREATE USER ''@'%' IDENTIFIED WITH some_plugin AS 'some_auth_string';
-- create proxied user for local connections CREATE USER 'developer'@'localhost' IDENTIFIED BY 'some_password'; -- create proxied user for remote connections CREATE USER 'developer'@'%' IDENTIFIED BY 'some_password';
GRANT PROXY ON 'developer'@'localhost' TO ''@'localhost'; GRANT PROXY ON 'developer'@'%' TO ''@'%';
some_pluginsome_plugin''@'localhost'''@'%'
mysql_native_passwordcheck_proxy_users
check_proxy_users
check_proxy_users
mysql_native_passwordmysql_native_password_proxy_users
sha256_passwordsha256_password_proxy_users
PROXY
proxy_user''@''
MySQL的> SELECT @@proxy_user;-------------- | @ @ proxy_user | -------------- |“@”| --------------
external_userNULL
ACCOUNT LOCKCREATE
USERALTER USER
CREATE USER
ALTER USER
account_lockedSHOW CREATE USER
Locked_connectsER_ACCOUNT_HAS_BEEN_LOCKED
用户“拒绝访问 user_name“@” host_name“.account也锁。
DEFINER
account_lockedaccount_lockedACCOUNT UNLOCK
mysql.userHostuser_namehost_name
CURRENT_USER()Host
CURRENT_USER()
SQL SECURITY DEFINER
SQL SECURITY DEFINER
DEFINERCURRENT_USER()USER()USER()CURRENT_USER()
''@'localhost'USER()CURRENT_USER()
MySQL的> SELECT USER(), CURRENT_USER();|十号用户(用户)的电流_ |(十)1号| | @本地主机| @本地主机|十号
'%'CURRENT_USER()user2user2USER()CURRENT_USER()
MySQL的> SELECT USER(), CURRENT_USER();-------------------------- --------------------- | user() | current_user() | -------------------------- --------------------- | user2@remote.example.com | user2 example.com | -------------------------- --------------------- @ %。
USER()USER()UserUserUser
''@'localhost'
RENAME USER ''@'localhost' TO 'user1'@'localhost'; RENAME USER 'user2'@'%.example.com' TO 'user2'@'remote.example.com';
user2
CURRENT_USER()USER()SUBSTRING_INDEX()
MySQL的> SELECT SUBSTRING_INDEX(CURRENT_USER(),'@',1);--------------------------------------- | substring_index(current_user(),“@”,1)| --------------------------------------- | user1 | --------------------------------------- MySQL > SELECT SUBSTRING_INDEX(CURRENT_USER(),'@',-1);---------------------------------------- | substring_index(current_user(),“@”- 1)| ---------------------------------------- | localhost | ----------------------------------------
REQUIRECREATE USERrequire_secure_transport
--ssl
--ssl-ca
--ssl-cert
--ssl-key
my.cnf
[mysqld]ssl-ca=ca.pemssl-cert=server-cert.pemssl-key=server-key.pem
mysql-test/std_data
--ssl--ssl-cipherxxx
ca.pemserver-key.pem
ssl_cassl_certssl_key
require_secure_transporttls_version
--ssl-mode
--ssl-mode--ssl-mode=PREFFERED
--ssl-mode=REQUIRED
--ssl-mode=DISABLED
--ssl-mode=VERIFY_CA--ssl-mode=VERIFY_IDENTITY
--ssl-cert--ssl-key
--ssl-ca
--ssl-cert
--ssl-key
--ssl-ca--ssl-capath--ssl-mode=VERIFY_CA
--ssl-mode=VERIFY_IDENTITY--ssl-mode=VERIFY_CA
CREATE USER--ssl-mode--ssl-mode=PREFFERED
MySQL
mysql --ssl-mode=PREFERRED
REQUIRE SSL
mysql --ssl-mode=REQUIRED
REQUIRE X509--ssl-cert--ssl-key--ssl-ca--ssl-capath
mysql --ssl-ca=ca.pem \ --ssl-cert=client-cert.pem \ --ssl-key=client-key.pem
REQUIRE ISSUERREQUIRE X509
REQUIRE
--ssl-xxx--ssl-mode=DISABLED
mysql --ssl-mode=DISABLED
--tls-version
Ssl_cipher
MySQL的> SHOW SESSION STATUS LIKE 'Ssl_cipher';|变量name)--------------------------- _ |值|)--------------------------- | SSL RSA密码| DHE - _ AES128 - GCM - | SHA256)---------------------------
STATUSSSL
MySQL的> \s...ssl:不使用…
mysql> \s
...
SSL: Cipher in use is DHE-RSA-AES128-GCM-SHA256
...
--ssl--ssl-mode
--ssl--sslxxx
--ssl--ssl-xxx--ssl=0--skip-ssl--disable-ssl
--ssl-cert--ssl-key--ssl-ca
--ssl
--ssl-ca--ssl-capath--ssl-ca--ssl-capath
--ssl
--ssl-ca--ssl-capath--ssl-ca--ssl-capath
--ssl-capath--ssl-ca
--ssl
--ssl
cipher_list
--ssl-cipher=AES128-SHA--ssl-cipher=DHE-RSA-AES128-GCM-SHA256:AES128-SHA
--ssl
--ssl-crl--ssl-crlpath
--ssl-crl
--ssl
--ssl-crl--ssl-crlpath
--ssl-crlpath
--ssl-fips-mode={OFF|ON|STRICT}
--ssl-fips-modexxx
--ssl-fips-mode
OFF
ON
STRICT
--ssl-fips-mode--ssl-fips-modeSTRICT
--ssl
PREFERRED--ssl-mode
REQUIRED
VERIFY_CA
VERIFY_IDENTITY
DISABLED
--ssl-mode
--ssl-mode--ssl-ca--ssl-capath--ssl-mode=VERIFY_CA
--ssl-modeVERIFY_IDENTITY--ssl-ca--ssl-capath
--ssl-modeVERIFY_IDENTITY--ssl-ca--ssl-capath
CREATE USERALTER USER
REQUIREREQUIRE
mysql --tls-version="TLSv1.1,TLSv1.2"
tls_version
sha256_password
auto_generate_certssha256_password_auto_generate_rsa_keyscaching_sha2_password_auto_generate_rsa_keys
auto_generate_certs--ssl
ca.pem server-cert.pem server-key.pem
ca.pem Self-signed CA certificate ca-key.pem CA private key server-cert.pem Server certificate server-key.pem Server private key client-cert.pem Client certificate client-key.pem Client private key
ca.pemserver-key.pemssl_cassl_certssl_key
sha256_password_auto_generate_rsa_keyscaching_sha2_password_auto_generate_rsa_keyscaching_sha2_password
private_key.pem Private member of private/public key pair public_key.pem Public member of private/public key pair
sha256_password_private_key_pathsha256_password_public_key_pathcaching_sha2_password_private_key_pathcaching_sha2_password_public_key_path
sha256WithRSAEncryption
ca.pem: MySQL_Server_suffix_Auto_Generated_CA_Certificate server-cert.pm: MySQL_Server_suffix_Auto_Generated_Server_Certificate client-cert.pm: MySQL_Server_suffix_Auto_Generated_Client_Certificate
suffix--suffix
_suffix
chown()--uid
openssl x509 -text -in ca.pem openssl x509 -text -in server-cert.pem openssl x509 -text -in client-cert.pem
mysql> SHOW STATUS LIKE 'Ssl_server_not%';
+-----------------------+--------------------------+
| Variable_name | Value |
+-----------------------+--------------------------+
| Ssl_server_not_after | Apr 28 14:16:39 2027 GMT |
| Ssl_server_not_before | May 1 14:16:39 2017 GMT |
+-----------------------+--------------------------+
ERROR 2026 (HY000): SSL connection error: error:00000001:lib(0):func(0):reason(1)
# Create clean environment
rm -rf newcerts
mkdir newcerts && cd newcerts
# Create CA certificate
openssl genrsa 2048 > ca-key.pem
openssl req -new -x509 -nodes -days 3600 \
-key ca-key.pem -out ca.pem
# Create server certificate, remove passphrase, and sign it
# server-cert.pem = public key, server-key.pem = private key
openssl req -newkey rsa:2048 -days 3600 \
-nodes -keyout server-key.pem -out server-req.pem
openssl rsa -in server-key.pem -out server-key.pem
openssl x509 -req -in server-req.pem -days 3600 \
-CA ca.pem -CAkey ca-key.pem -set_serial 01 -out server-cert.pem
# Create client certificate, remove passphrase, and sign it
# client-cert.pem = public key, client-key.pem = private key
openssl req -newkey rsa:2048 -days 3600 \
-nodes -keyout client-key.pem -out client-req.pem
openssl rsa -in client-key.pem -out client-key.pem
openssl x509 -req -in client-req.pem -days 3600 \
-CA ca.pem -CAkey ca-key.pem -set_serial 01 -out client-cert.pem
openssl verify -CAfile ca.pem server-cert.pem client-cert.pem
server-cert.pem: OK client-cert.pem: OK
openssl x509 -text -in ca.pem openssl x509 -text -in server-cert.pem openssl x509 -text -in client-cert.pem
ca.pem--ssl-ca
server-cert.pem--ssl-cert--ssl-key
client-cert.pem--ssl-cert--ssl-key
DIR=`pwd`/openssl
PRIV=$DIR/private
mkdir $DIR $PRIV $DIR/newcerts
cp /usr/share/ssl/openssl.cnf $DIR
replace ./demoCA $DIR -- $DIR/openssl.cnf
# Create necessary files: $database, $serial and $new_certs_dir
# directory (optional)
touch $DIR/index.txt
echo "01" > $DIR/serial
#
# Generation of Certificate Authority(CA)
#
openssl req -new -x509 -keyout $PRIV/cakey.pem -out $DIR/ca.pem \
-days 3600 -config $DIR/openssl.cnf
# Sample output:
# Using configuration from /home/monty/openssl/openssl.cnf
# Generating a 1024 bit RSA private key
# ................++++++
# .........++++++
# writing new private key to '/home/monty/openssl/private/cakey.pem'
# Enter PEM pass phrase:
# Verifying password - Enter PEM pass phrase:
# -----
# You are about to be asked to enter information that will be
# incorporated into your certificate request.
# What you are about to enter is what is called a Distinguished Name
# or a DN.
# There are quite a few fields but you can leave some blank
# For some fields there will be a default value,
# If you enter '.', the field will be left blank.
# -----
# Country Name (2 letter code) [AU]:FI
# State or Province Name (full name) [Some-State]:.
# Locality Name (eg, city) []:
# Organization Name (eg, company) [Internet Widgits Pty Ltd]:MySQL AB
# Organizational Unit Name (eg, section) []:
# Common Name (eg, YOUR name) []:MySQL admin
# Email Address []:
#
# Create server request and key
#
openssl req -new -keyout $DIR/server-key.pem -out \
$DIR/server-req.pem -days 3600 -config $DIR/openssl.cnf
# Sample output:
# Using configuration from /home/monty/openssl/openssl.cnf
# Generating a 1024 bit RSA private key
# ..++++++
# ..........++++++
# writing new private key to '/home/monty/openssl/server-key.pem'
# Enter PEM pass phrase:
# Verifying password - Enter PEM pass phrase:
# -----
# You are about to be asked to enter information that will be
# incorporated into your certificate request.
# What you are about to enter is what is called a Distinguished Name
# or a DN.
# There are quite a few fields but you can leave some blank
# For some fields there will be a default value,
# If you enter '.', the field will be left blank.
# -----
# Country Name (2 letter code) [AU]:FI
# State or Province Name (full name) [Some-State]:.
# Locality Name (eg, city) []:
# Organization Name (eg, company) [Internet Widgits Pty Ltd]:MySQL AB
# Organizational Unit Name (eg, section) []:
# Common Name (eg, YOUR name) []:MySQL server
# Email Address []:
#
# Please enter the following 'extra' attributes
# to be sent with your certificate request
# A challenge password []:
# An optional company name []:
#
# Remove the passphrase from the key
#
openssl rsa -in $DIR/server-key.pem -out $DIR/server-key.pem
#
# Sign server cert
#
openssl ca -cert $DIR/ca.pem -policy policy_anything \
-out $DIR/server-cert.pem -config $DIR/openssl.cnf \
-infiles $DIR/server-req.pem
# Sample output:
# Using configuration from /home/monty/openssl/openssl.cnf
# Enter PEM pass phrase:
# Check that the request matches the signature
# Signature ok
# The Subjects Distinguished Name is as follows
# countryName :PRINTABLE:'FI'
# organizationName :PRINTABLE:'MySQL AB'
# commonName :PRINTABLE:'MySQL admin'
# Certificate is to be certified until Sep 13 14:22:46 2003 GMT
# (365 days)
# Sign the certificate? [y/n]:y
#
#
# 1 out of 1 certificate requests certified, commit? [y/n]y
# Write out database with 1 new entries
# Data Base Updated
#
# Create client request and key
#
openssl req -new -keyout $DIR/client-key.pem -out \
$DIR/client-req.pem -days 3600 -config $DIR/openssl.cnf
# Sample output:
# Using configuration from /home/monty/openssl/openssl.cnf
# Generating a 1024 bit RSA private key
# .....................................++++++
# .............................................++++++
# writing new private key to '/home/monty/openssl/client-key.pem'
# Enter PEM pass phrase:
# Verifying password - Enter PEM pass phrase:
# -----
# You are about to be asked to enter information that will be
# incorporated into your certificate request.
# What you are about to enter is what is called a Distinguished Name
# or a DN.
# There are quite a few fields but you can leave some blank
# For some fields there will be a default value,
# If you enter '.', the field will be left blank.
# -----
# Country Name (2 letter code) [AU]:FI
# State or Province Name (full name) [Some-State]:.
# Locality Name (eg, city) []:
# Organization Name (eg, company) [Internet Widgits Pty Ltd]:MySQL AB
# Organizational Unit Name (eg, section) []:
# Common Name (eg, YOUR name) []:MySQL user
# Email Address []:
#
# Please enter the following 'extra' attributes
# to be sent with your certificate request
# A challenge password []:
# An optional company name []:
#
# Remove the passphrase from the key
#
openssl rsa -in $DIR/client-key.pem -out $DIR/client-key.pem
#
# Sign client cert
#
openssl ca -cert $DIR/ca.pem -policy policy_anything \
-out $DIR/client-cert.pem -config $DIR/openssl.cnf \
-infiles $DIR/client-req.pem
# Sample output:
# Using configuration from /home/monty/openssl/openssl.cnf
# Enter PEM pass phrase:
# Check that the request matches the signature
# Signature ok
# The Subjects Distinguished Name is as follows
# countryName :PRINTABLE:'FI'
# organizationName :PRINTABLE:'MySQL AB'
# commonName :PRINTABLE:'MySQL user'
# Certificate is to be certified until Sep 13 16:45:17 2003 GMT
# (365 days)
# Sign the certificate? [y/n]:y
#
#
# 1 out of 1 certificate requests certified, commit? [y/n]y
# Write out database with 1 new entries
# Data Base Updated
#
# Create a my.cnf file that you can use to test the certificates
#
cat <<EOF > $DIR/my.cnf
[client]
ssl-ca=$DIR/ca.pem
ssl-cert=$DIR/client-cert.pem
ssl-key=$DIR/client-key.pem
[mysqld]
ssl-ca=$DIR/ca.pem
ssl-cert=$DIR/server-cert.pem
ssl-key=$DIR/server-key.pem
EOF
http://www.slproweb.com/products/Win32OpenSSL.html
C:\OpenSSL-Win32C:\OpenSSL-Win32
'...critical component is missing: Microsoft Visual
C++ 2008 Redistributables'
http://www.microsoft.com/downloads/details.aspx?familyid=9B2DA534-3E03-4391-8A4D-074B9F2BC1BF
http://www.microsoft.com/downloads/details.aspx?familyid=bd2a6171-e2d6-4230-b809-9a8d7548c1b6
C:\OpenSSL-Win32
C:\OpenSSL-Win32\bin
';C:\OpenSSL-Win32\bin'
Microsoft Windows [Version ...] Copyright (c) 2006 Microsoft Corporation. All rights reserved. C:\Windows\system32>cd \C:\>opensslOpenSSL>exit<<< If you see the OpenSSL prompt, installation was successful. C:\>
# Create clean environment rm -rf newcerts mkdir newcerts && cd newcerts
# Create clean environment md c:\newcerts cd c:\newcerts
'\'
sha256_password
openssl genrsa -out private_key.pem 2048 openssl rsa -in private_key.pem -pubout -out public_key.pem
chmod 400 private_key.pem chmod 444 public_key.pem
--ssl-cipher--ssl-capath--ssl-crl--ssl-crlpath
sha256_passwordcaching_sha2_password
AES_ENCRYPT()AES_DECRYPT()
SHOW STATUS LIKE 'Rsa_public_key';
WITH_SSL-DWITH_SSL=system
cmake . -DWITH_SSL=system
cmake . -DWITH_SSL=path_name
extra/README-wolfssl.txt
have_ssl
MySQL的> SHOW VARIABLES LIKE 'have_ssl';--------------- ------- | variable_name |价值| --------------- ------- | have_ssl |是| --------------- -------
YES--ssl-xxx
Ssl_versionSsl_cipher
MySQL的> SHOW SESSION STATUS LIKE 'Ssl_version';------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ SHOW SESSION STATUS LIKE 'Ssl_cipher';|变量name)--------------------------- _ |值|)--------------------------- | SSL RSA密码| DHE - _ AES128 - GCM - | SHA256)---------------------------
tls_versiontls_versiontls_version
MySQL的> SHOW GLOBAL VARIABLES LIKE 'tls_version';--------------- ----------------------- | _ name值变| | -------- ----------------------- | TLS _ | tlsv1版本,tlsv1.1,tlsv1.2 ----------------------- | ---------------
tls_version
[mysqld] tls_version=TLSv1.1,TLSv1.2
tls_version
[mysqld]tls_version=TLSv1.2
--tls-versiontls_version
tls_version--tls-version
--ssl-cipher
aes128-shaaes128-sha256aes256-shaaes256-sha256camellia128-shacamellia256-shades-cbc3-shadhe-rsa-aes256-sharc4-md5rc4-shaseed-sha
tls_version=TLSv1.1,TLSv1.2--tls-version=TLSv1--tls-version
Ssl_cipher_list
显示会话状态像ssl_cipher_list”;
ECDHE-ECDSA-AES128-GCM-SHA256 ECDHE-ECDSA-AES256-GCM-SHA384 ECDHE-RSA-AES128-GCM-SHA256 ECDHE-RSA-AES256-GCM-SHA384 ECDHE-ECDSA-AES128-SHA256 ECDHE-RSA-AES128-SHA256 ECDHE-ECDSA-AES256-SHA384 ECDHE-RSA-AES256-SHA384 DHE-RSA-AES128-GCM-SHA256 DHE-DSS-AES128-GCM-SHA256 DHE-RSA-AES128-SHA256 DHE-DSS-AES128-SHA256 DHE-DSS-AES256-GCM-SHA384 DHE-RSA-AES256-SHA256 DHE-DSS-AES256-SHA256 ECDHE-RSA-AES128-SHA ECDHE-ECDSA-AES128-SHA ECDHE-RSA-AES256-SHA ECDHE-ECDSA-AES256-SHA DHE-DSS-AES128-SHA DHE-RSA-AES128-SHA TLS_DHE_DSS_WITH_AES_256_CBC_SHA DHE-RSA-AES256-SHA AES128-GCM-SHA256 DH-DSS-AES128-GCM-SHA256 ECDH-ECDSA-AES128-GCM-SHA256 AES256-GCM-SHA384 DH-DSS-AES256-GCM-SHA384 ECDH-ECDSA-AES256-GCM-SHA384 AES128-SHA256 DH-DSS-AES128-SHA256 ECDH-ECDSA-AES128-SHA256 AES256-SHA256 DH-DSS-AES256-SHA256 ECDH-ECDSA-AES256-SHA384 AES128-SHA DH-DSS-AES128-SHA ECDH-ECDSA-AES128-SHA AES256-SHA DH-DSS-AES256-SHA ECDH-ECDSA-AES256-SHA DHE-RSA-AES256-GCM-SHA384 DH-RSA-AES128-GCM-SHA256 ECDH-RSA-AES128-GCM-SHA256 DH-RSA-AES256-GCM-SHA384 ECDH-RSA-AES256-GCM-SHA384 DH-RSA-AES128-SHA256 ECDH-RSA-AES128-SHA256 DH-RSA-AES256-SHA256 ECDH-RSA-AES256-SHA384 ECDHE-RSA-AES128-SHA ECDHE-ECDSA-AES128-SHA ECDHE-RSA-AES256-SHA ECDHE-ECDSA-AES256-SHA DHE-DSS-AES128-SHA DHE-RSA-AES128-SHA TLS_DHE_DSS_WITH_AES_256_CBC_SHA DHE-RSA-AES256-SHA AES128-SHA DH-DSS-AES128-SHA ECDH-ECDSA-AES128-SHA AES256-SHA DH-DSS-AES256-SHA ECDH-ECDSA-AES256-SHA DH-RSA-AES128-SHA ECDH-RSA-AES128-SHA DH-RSA-AES256-SHA ECDH-RSA-AES256-SHA DES-CBC3-SHA
!DHE-DSS-DES-CBC3-SHA !DHE-RSA-DES-CBC3-SHA !ECDH-RSA-DES-CBC3-SHA !ECDH-ECDSA-DES-CBC3-SHA !ECDHE-RSA-DES-CBC3-SHA !ECDHE-ECDSA-DES-CBC3-SHA
!aNULL !eNULL !EXPORT !LOW !MD5 !DES !RC2 !RC4 !PSK !SSLv3
<dcarlson@mplcomm.com>
Host_Name =
yourmysqlserver_URL_or_IPuserid=your_userid
local_port: 3306yourmysqlservername_or_ipport: 3306remote port: 3306
localhostyourmysqlservername
default_authentication_plugin
mysql_native_password
mysql_native_password
libmysqlclient
mysql_native_password--default-auth
内核> mysql --default-auth=mysql_native_password ...
sha256_password
caching_sha2_password
caching_sha2_password
sha256_password
sha256_passwordcaching_sha2_password
sha256_password
libmysqlclient
sha256_passwordpassword
创建用户的sha256user”@ 'localhost'identified与sha256_password ' password';
sha256_passwordauthentication_string
sha256_passwordCREATE USER
sha256_password
[mysqld]default_authentication_plugin=sha256_password
sha256_password
创建用户的sha256user '@'本地主机'确定' password';
default_authentication_pluginmysql_native_password
创建用户的nativeuser”@ 'localhost'identified与mysql_native_password ' password';
sha256_password
sha256_password
sha256_password_private_key_pathsha256_password_public_key_path
sha256_password_auto_generate_rsa_keys
Rsa_public_key
sha256_password
--server-public-key-path
mysql_options()
CHANGE MASTER TOgroup_replication_recovery_get_public_key
sha256_password
sha256_password
private_key.pemsha256_password_private_key_pathsha256_password_public_key_path
[mysqld] sha256_password_private_key_path=myprivkey.pem sha256_password_public_key_path=mypubkey.pem
[mysqld] sha256_password_private_key_path=/usr/local/mysql/myprivkey.pem sha256_password_public_key_path=/usr/local/mysql/mypubkey.pem
Rsa_public_key
MySQL的> SHOW STATUS LIKE 'Rsa_public_key'\G*************************** 1。行*************************** variable_name:rsa_public_key价值:-----开始公开密钥----- migfma0gcsqgsib3dqebaquaa4gnadcbiqkbgqdo9nrudd kvszgy7cnbzmnpwx6mve1pbjfxo7u18nj9lwc99du / e7lw6cvxw7vkrxpehbvquzgyunkf45nz / ckaajaalgjobcidmnvnyu54ot / 1lcs2xiyfadme8fcj64zwtnkby2gkt1imjuab5ogd5kjg8av7etkwyhhb0c30qidaqab -----端公钥-----
sha256_password
内核> mysql --ssl-mode=DISABLED -u sha256user -p输入密码: password
sha256userCREATE USER
--server-public-key-path
内核> mysql --ssl-mode=DISABLED -u sha256user -p --server-public-key-path=file_name输入密码: password
--server-public-key-pathsha256_password_public_key_path--server-public-key-path
SHOW STATUS LIKE
'Rsa_public_key'
sha256_password
caching_sha2_password
caching_sha2_password
caching_sha2_password
sha256_passwordcaching_sha2_password
caching_sha2_password
caching_sha2_password
libmysqlclient
sha2_cache_cleanercaching_sha2_password
caching_sha2_passwordpassword
创建用户的sha2user”@ 'localhost'identified与caching_sha2_password ' password';
caching_sha2_passwordauthentication_string
caching_sha2_passwordCREATE
USER
caching_sha2_password
[mysqld]default_authentication_plugin=caching_sha2_password
caching_sha2_password
创建用户的sha2user '@'本地主机'确定' password';
default_authentication_pluginmysql_native_password
创建用户的nativeuser”@ 'localhost'identified与mysql_native_password ' password';
caching_sha2_password
caching_sha2_password_private_key_pathcaching_sha2_password_public_key_path
caching_sha2_password_auto_generate_rsa_keys
Caching_sha2_password_rsa_public_key
caching_sha2_password
--server-public-key-path--get-server-public-key
mysql_options()MYSQL_OPT_GET_SERVER_PUBLIC_KEY
CHANGE MASTER TOGET_MASTER_PUBLIC_KEYgroup_replication_recovery_public_key_pathgroup_replication_recovery_get_public_key
caching_sha2_password
private_key.pemcaching_sha2_password_private_key_pathcaching_sha2_password_public_key_path
[mysqld] caching_sha2_password_private_key_path=myprivkey.pem caching_sha2_password_public_key_path=mypubkey.pem
[mysqld] caching_sha2_password_private_key_path=/usr/local/mysql/myprivkey.pem caching_sha2_password_public_key_path=/usr/local/mysql/mypubkey.pem
Caching_sha2_password_rsa_public_key
MySQL的> SHOW STATUS LIKE 'Caching_sha2_password_rsa_public_key'\G*************************** 1。行*************************** variable_name:caching_sha2_password_rsa_public_key价值:-----开始公开密钥----- migfma0gcsqgsib3dqebaquaa4gnadcbiqkbgqdo9nrudd kvszgy7cnbzmnpwx6mve1pbjfxo7u18nj9lwc99du / e7lw6cvxw7vkrxpehbvquzgyunkf45nz / ckaajaalgjobcidmnvnyu54ot / 1lcs2xiyfadme8fcj64zwtnkby2gkt1imjuab5ogd5kjg8av7etkwyhhb0c30qidaqab -----端公钥-----
caching_sha2_password
内核> mysql --ssl-mode=DISABLED -u sha2user -p输入密码: password
sha2userCREATE USER
错误2061(hy000):身份验证插件的caching_sha2_password'reported错误:认证需要安全连接。
--get-server-public-key
内核> mysql --ssl-mode=DISABLED -u sha2user -p --get-server-public-key输入密码: password
--server-public-key-path
内核> mysql --ssl-mode=DISABLED -u sha2user -p --server-public-key-path=file_name输入密码: password
--server-public-key-pathcaching_sha2_password_public_key_path
SHOW STATUS LIKE
'Caching_sha2_password_rsa_public_key'
caching_sha2_password
caching_sha2_password
mysql.user
mysql.user
sha2_cache_cleaner
FLUSH
PRIVILEGES
RENAME USER
FLUSH PRIVILEGES
mysql_clear_password
mysql_clear_password
LIBMYSQL_ENABLE_CLEARTEXT_PLUGINY
--enable-cleartext-plugin
mysql_options()libmysqlclient
joe
'Authentication succeeded, Username is
user_name'
plugin_dir
authentication_pam | |
mysql_clear_password | |
authentication_pam.so |
libmysqlclient
mysql_clear_password
plugin_dirplugin_dir
authentication_pam.dll
--plugin-load-add.so
[mysqld]plugin-load-add=authentication_pam.so
my.cnf
.so
插件是安装_ PAM认证soname _ pam.so认证;
INSTALL PLUGIN
INFORMATION_SCHEMA.PLUGINSSHOW PLUGINS
mysql>SELECT PLUGIN_NAME, PLUGIN_STATUSFROM INFORMATION_SCHEMA.PLUGINSWHERE PLUGIN_NAME LIKE '%pam%';+--------------------+---------------+ | PLUGIN_NAME | PLUGIN_STATUS | +--------------------+---------------+ | authentication_pam | ACTIVE | +--------------------+---------------+
--plugin-load-add
INSTALL PLUGINUNINSTALL PLUGIN
authentication_pam卸载插件;
IDENTIFIED WITHCREATE USER
CREATE USERuserIDENTIFIED WITH authentication_pam AS 'authentication_string';
mysqlusersdata_entry
创建用户 userIDENTIFIED WITH authentication_pam AS 'mysql, root=developer, users=data_entry';
pam_service_name[,group_name=mysql_user_name]...
group_name=mysql_user_name
pam_service_namegroup_namemysql_user_name
pam_service_namegroup_namemysql_user_name
group_name=mysql_user_namegroup_namemysql_user_name
user_name@host_nameuser_namehost_name
/etc/pam.d
mysqlmysqlauth_stringCREATE USER
antonio
AUTHENTICATION_PAM_LOG
antonio
mysql/etc/pam.d
#%PAM-1.0 auth include password-auth account include password-auth
system-loginlogin
@include common-auth @include common-account @include common-session-noninteractive
CREATE USER 'antonio'@'localhost' IDENTIFIED WITH authentication_pam AS 'mysql'; GRANT ALL PRIVILEGES ON mydb.* TO 'antonio'@'localhost';
mysql --user=antonio --password --enable-cleartext-plugin mydb
Enter password: verysecret
mysql> SELECT USER(), CURRENT_USER(), @@proxy_user;
+-------------------+-------------------+--------------+
| USER() | CURRENT_USER() | @@proxy_user |
+-------------------+-------------------+--------------+
| antonio@localhost | antonio@localhost | NULL |
+-------------------+-------------------+--------------+
antonio
mysql_clear_password
mysql_clear_password
mysql_clear_password
/etc/shadow/etc/shadow/etc/shadow
shadow
mysql/etc/group
/etc/group
chgrp shadow /etc/shadow chmod g+r /etc/shadow
antonio
mysql/etc/pam.d
#%PAM-1.0 auth required pam_ldap.so account required pam_ldap.so
.so
/etc/shadow
antonioantoniousers
mysql
#%PAM-1.0 auth include password-auth account include password-auth
system-loginlogin
@include common-auth @include common-account @include common-session-noninteractive
''@''developerdata_entry
CREATE USER ''@'' IDENTIFIED WITH authentication_pam AS 'mysql, root=developer, users=data_entry';
CREATE USER 'developer'@'localhost' IDENTIFIED BY 'very secret password'; GRANT ALL PRIVILEGES ON mydevdb.* TO 'developer'@'localhost'; CREATE USER 'data_entry'@'localhost' IDENTIFIED BY 'very secret password'; GRANT ALL PRIVILEGES ON mydb.* TO 'data_entry'@'localhost';
developer
PROXY
在线代理developer格兰特是是是是是是“localhost”格兰特是代理;在线日期输入localhost是_ @ @是是是是是是;
mysql --user=antonio --password --enable-cleartext-plugin mydb
Enter password: verysecret
''@''antonioroot''@''PROXY
mysql> SELECT USER(), CURRENT_USER(), @@proxy_user;
+-------------------+---------------------+--------------+
| USER() | CURRENT_USER() | @@proxy_user |
+-------------------+---------------------+--------------+
| antonio@localhost | developer@localhost | ''@'' |
+-------------------+---------------------+--------------+
antonio
antoniousersdata_entrydata_entry
MySQL的> SELECT USER(), CURRENT_USER(), @@proxy_user;------------------- ---------------------- -------------- | user() | current_user() | @ @ proxy_user | ------------------- ---------------------- -------------- |安东尼奥@本地| data_entry @本地|“@”| ------------------- ---------------------- --------------
mysql_clear_password
mysql_clear_password
mysql_clear_password
joe
plugin_dir
authentication_windows | |
authentication_windows_client | |
authentication_windows.dll |
libmysqlclient
plugin_dirplugin_dir
--plugin-load-add
[mysqld] plugin-load-add=authentication_windows.dll
my.cnf
INSTALL PLUGIN authentication_windows SONAME 'authentication_windows.dll';
INSTALL PLUGIN
INFORMATION_SCHEMA.PLUGINSSHOW PLUGINS
mysql>SELECT PLUGIN_NAME, PLUGIN_STATUSFROM INFORMATION_SCHEMA.PLUGINSWHERE PLUGIN_NAME LIKE '%windows%';+------------------------+---------------+ | PLUGIN_NAME | PLUGIN_STATUS | +------------------------+---------------+ | authentication_windows | ACTIVE | +------------------------+---------------+
--plugin-load-add
INSTALL PLUGINUNINSTALL PLUGIN
_插件卸载Windows认证;
IDENTIFIED WITHCREATE USERRafalAdministratorssql_admin
创建用户sql_admin确定authentication_windows ' Rafal,塔莎,管理员,“超级用户”;
authentication_windowsRafalsql_adminPower
Users
sql_admin
C:\> mysql --user=sql_admin
authentication_windowsTashaPower
Userssql_admin
win_user_or_group_name=mysql_user_namewin_user_or_group_name
mysql_user_nameCREATE USER
CREATE USER sql_admin IDENTIFIED WITH authentication_windows AS 'Rafal, Tasha, Administrators, "Power Users"';CREATE USER sql_admin IDENTIFIED WITH authentication_windows AS 'Rafal=sql_admin, Tasha=sql_admin, Administrators=sql_admin, "Power Users"=sql_admin';
'\'
win_user_or_group_namemysql_user_name
win_user_or_group_namemysql_user_name
win_user_or_group_name
域\\用户。\\用户域\\组。\\ \\ wellknowngroup groupbuiltin
mysql_user_name
win_user
'win_group = sql_user1, win_user = sql_user2'
win_userwin_user
CREATE USER sql_accounting IDENTIFIED WITH authentication_windows AS 'SomeDomain\\Accounting';
SomeDomain
local_userlocal_wlad
MyDomain\Developers
local_admin
local_wladlocal_adminlocal_wladlocal_admin
CREATE USER win_proxy
IDENTIFIED WITH authentication_windows
AS 'local_user = local_wlad,
MyDomain\\domain_user = local_wlad,
MyDomain\\Developers = local_dev,
BUILTIN\\Administrators = local_admin';
CREATE USER local_wlad IDENTIFIED BY 'wlad_pass'; CREATE USER local_dev IDENTIFIED BY 'dev_pass'; CREATE USER local_admin IDENTIFIED BY 'admin_pass';
GRANT
PROXY
格兰特_ wlad赢得当地代理我们_代理;代理我们_格兰特赢得当地发展_代理;代理我们_格兰特赢得当地行政_代理;
local_userwin_proxyMyDomain\Developerslocal_devlocal_admin
''@''
authentication_windows_use_principal_nameauthentication_windows_log_level
joejoe
plugin_dir
authentication_ldap_sasl | |
authentication_ldap_sasl_client | |
authentication_ldap_sasl.soauthentication_ldap_simple.so |
authentication_ldap_XXXlibmysqlclient
authentication_ldap_simple
authentication_ldap_sasl
mysql_clear_password
authentication_pam
authentication_ldap_sasl
authentication_ldap_sasl_client
BYCREATE USER
cn
plugin_dirplugin_dir
authentication_ldap_sasl.so
--plugin-load-add
my.cnf
[mysqld] plugin-load-add=authentication_ldap_sasl.so authentication_ldap_sasl_server_host=127.0.0.1 authentication_ldap_sasl_bind_base_dn="dc=example,dc=com" plugin-load-add=authentication_ldap_simple.so authentication_ldap_simple_server_host=127.0.0.1 authentication_ldap_simple_bind_base_dn="dc=example,dc=com"
my.cnf
.so
安装插件的LDAP认证_ _ SASL认证soname’_ LDAP _ sasl.so;安装插件_ LDAP认证_简单soname’_ _ simple.so LDAP认证;
INSTALL PLUGIN
my.cnf
[mysqld]authentication_ldap_sasl_server_host=127.0.0.1authentication_ldap_sasl_bind_base_dn="dc=example,dc=com"authentication_ldap_simple_server_host=127.0.0.1authentication_ldap_simple_bind_base_dn="dc=example,dc=com"
my.cnf
INFORMATION_SCHEMA.PLUGINSSHOW PLUGINS
mysql>SELECT PLUGIN_NAME, PLUGIN_STATUSFROM INFORMATION_SCHEMA.PLUGINSWHERE PLUGIN_NAME LIKE '%ldap%';+----------------------------+---------------+ | PLUGIN_NAME | PLUGIN_STATUS | +----------------------------+---------------+ | authentication_ldap_sasl | ACTIVE | | authentication_ldap_simple | ACTIVE | +----------------------------+---------------+
mysqlldap.te
module mysqlldap 1.0;require { type ldap_port_t; type mysqld_t; class tcp_socket name_connect;}#============= mysqld_t ==============allow mysqld_t ldap_port_t:tcp_socket name_connect;checkmodule -M -m mysqlldap.te -o mysqlldap.mod
semodule_package -m mysqlldap.mod -o mysqlldap.pp
semodule -i mysqlldap.pp
service mysqld restart
--plugin-load-add
INSTALL PLUGINUNINSTALL PLUGIN
卸载插件authentication_ldap_sasl;卸载插件authentication_ldap_simple;
my.cnf
authentication_ldap_simple
authentication_ldap_sasl
BYCREATE USER
authentication_ldap_simplemysql_clear_password
betsybetsy_ldap
uiduid
uid=betsy_ldap,pwd=pwd1,ou=People,dc=example,dc=com uid=boris_ldap,pwd=pwd2,ou=People,dc=example,dc=com
CREATE USER
CREATE USER
CREATE USERuserIDENTIFIED WITH authentication_ldap_simple [BY 'LDAP user DN'];
betsy
uid=betsy_ldap,pwd=pwd1,ou=People,dc=example,dc=com
betsy
CREATE USER 'betsy'@'localhost' IDENTIFIED WITH authentication_ldap_simple BY 'uid=betsy_ldap,ou=People,dc=example,dc=com';
BY
mysql_clear_password
内核> mysql --user=betsy --password --enable-cleartext-plugin输入密码: pwd1(betsy_ldap LDAP password)
mysql_clear_password
mysql_clear_password
mysql_clear_password
betsy
'betsy'@'localhost''uid=betsy_ldap,ou=People,dc=example,dc=com'
betsy_ldap
betsy
betsy
CREATE USERbetsy_ldapbetsy
CREATE USER
CREATE USERuserIDENTIFIED WITH authentication_ldap_sasl [BY 'LDAP user DN'];
boris
uid=boris_ldap,pwd=pwd2,ou=People,dc=example,dc=com
boris
CREATE USER 'boris'@'localhost' IDENTIFIED WITH authentication_ldap_sasl BY 'uid=boris_ldap,ou=People,dc=example,dc=com';
BY
shell>mysql --user=boris --passwordEnter password:pwd2(boris_ldap LDAP password)
authentication_ldap_sasl--plugin-dir
boris
+cnmysql.user
+
CREATE USER 'admin' IDENTIFIED WITH authentication_ldap_simple BY "cn=admin,ou=People,dc=example,dc=com";
+
CREATE USER 'accounting' IDENTIFIED WITH authentication_ldap_simple BY "+ou=People,dc=example,dc=com";
accounting"cn=accounting,ou=People,dc=example,dc=com"
uid
authentication_ldap_simpleauthentication_ldap_simple_user_search_attrauthentication_ldap_simple_group_search_attr
authentication_ldap_saslauthentication_ldap_sasl_user_search_attrauthentication_ldap_sasl_group_search_attr
uid=basha,pwd=pwd3,ou=People,dc=example,dc=com,cn=accounting uid=basil,pwd=pwd4,ou=People,dc=example,dc=com,cn=front_office
accounting
CREATE USER ''@'%' IDENTIFIED WITH authentication_ldap_sasl;
BY
'auth_string'
CREATE USER 'accounting'@'localhost' ACCOUNT LOCK; CREATE USER 'front_office'@'localhost' ACCOUNT LOCK; GRANT ALL PRIVILEGES ON accountingdb.* TO 'accounting'@'localhost'; GRANT ALL PRIVILEGES ON frontdb.* TO 'front_office'@'localhost';
PROXY
格兰特会计'@'本地主机' '“”“%”代理;授权代理的front_office '@'本地主机' '“”“%”;
basha
shell>mysql --user=basha --passwordEnter password:pwd3(basha LDAP password)
''@'%'cn=accountingbashaaccountingaccounting
MySQL的> SELECT USER(), CURRENT_USER(), @@proxy_user;----------------- ---------------------- -------------- | user() | current_user() | @ @ proxy_user | ----------------- ---------------------- -------------- |岜@本地|会计@本地|”@“%”| ----------------- ---------------------- --------------
basha
basil
内核> mysql --user=basil --password输入密码: pwd4(basil LDAP password)
basilcn=front_officebasilfront_officefront_office
MySQL的> SELECT USER(), CURRENT_USER(), @@proxy_user;----------------- ------------------------ -------------- | user() | current_user() | @ @ proxy_user | ----------------- ------------------------ -------------- |罗勒@本地| front_office @本地|”@“%”| ----------------- ------------------------ --------------
basil
mysql_no_login
plugin_dir
plugin_dirplugin_dir
mysql_no_login.dll
--plugin-load-add.so
[mysqld]plugin-load-add=mysql_no_login.so
my.cnf
.so
安装插件mysql_no_login现在的mysql_no_login。”;
INSTALL PLUGIN
INFORMATION_SCHEMA.PLUGINSSHOW PLUGINS
mysql>SELECT PLUGIN_NAME, PLUGIN_STATUSFROM INFORMATION_SCHEMA.PLUGINSWHERE PLUGIN_NAME LIKE '%login%';+----------------+---------------+ | PLUGIN_NAME | PLUGIN_STATUS | +----------------+---------------+ | mysql_no_login | ACTIVE | +----------------+---------------+
--plugin-load-add
INSTALL PLUGINUNINSTALL PLUGIN
mysql_no_login卸载插件;
IDENTIFIED WITHCREATE USER
mysql_no_loginSQL SECURITY DEFINER
mysql.user
CREATE DATABASE nologindb;CREATE USER 'nologin'@'localhost' IDENTIFIED WITH mysql_no_login;GRANT ALL ON nologindb.* TO 'nologin'@'localhost';GRANT SELECT ON mysql.user TO 'nologin'@'localhost';CREATE DEFINER = 'nologin'@'localhost' SQL SECURITY DEFINER VIEW nologindb.myview AS SELECT User, Host FROM mysql.user;
GRANT SELECT ON nologindb.myview TO 'ordinaryuser'@'localhost';
SELECT * FROM nologindb.myview;
nologinDEFINER
mysql_no_login
——创建代理accountcreate用户proxy_base '@'本地主机'确定mysql_no_login;——授予权限的代理accountgrant…“proxy_base '@'本地主机';--允许real_user是代理的代理的代理的accountgrant proxy_base '@'本地主机' ' real_user '@'本地主机';
real_user
auth_socketSO_PEERCRED
plugin_dir
plugin_dirplugin_dir
--plugin-load-add
[mysqld] plugin-load-add=auth_socket.so
my.cnf
INSTALL PLUGIN auth_socket SONAME 'auth_socket.so';
INSTALL PLUGIN
INFORMATION_SCHEMA.PLUGINSSHOW PLUGINS
mysql>SELECT PLUGIN_NAME, PLUGIN_STATUSFROM INFORMATION_SCHEMA.PLUGINSWHERE PLUGIN_NAME LIKE '%socket%';+-------------+---------------+ | PLUGIN_NAME | PLUGIN_STATUS | +-------------+---------------+ | auth_socket | ACTIVE | +-------------+---------------+
--plugin-load-add
INSTALL PLUGINUNINSTALL PLUGIN
auth_socket卸载插件;
authentication_stringauthentication_stringCREATE USERALTER USER
valerie
CREATE USER 'valerie'@'localhost' IDENTIFIED WITH auth_socket;
stefanie--user=valerie--userstephanievalerie
valerie
CREATE USER
创建用户瓦莱丽'@'本地主机'确定'斯蒂芬妮' auth_socket;
CREATE
USERALTER USER
创建用户瓦莱丽'@'本地主机'确定auth_socket;改变用户瓦莱丽'@'本地主机'确定'斯蒂芬妮' auth_socket;
valerie--user=valerie
plugin_dir
plugin_dirplugin_dir
--plugin-load-add.so
[mysqld]plugin-load-add=auth_test_plugin.so
my.cnf
.so
测试插件安装插件_ auth服务器是_ soname _ _ plugin.so测试;
INSTALL PLUGIN
INFORMATION_SCHEMA.PLUGINSSHOW PLUGINS
mysql>SELECT PLUGIN_NAME, PLUGIN_STATUSFROM INFORMATION_SCHEMA.PLUGINSWHERE PLUGIN_NAME LIKE '%test_plugin%';+--------------------+---------------+ | PLUGIN_NAME | PLUGIN_STATUS | +--------------------+---------------+ | test_plugin_server | ACTIVE | +--------------------+---------------+
--plugin-load-add
INSTALL PLUGINUNINSTALL PLUGIN
test_plugin_server卸载插件;
IDENTIFIED WITH
创建用户的testuser”@ 'localhost'identified与test_plugin_serverby testpassword ' ';
--user--password
内核> mysql --user=testuser --password输入密码: testpassword
authentication_stringauthentication_string
[Note] Plugin test_plugin_server reported: 'successfully authenticated user testpassword'
authentication_ldap_saslxxx
authentication_ldap_simplexxx
authentication_ldap_sasl_auth_method_name
--authentication-ldap-sasl-auth-method-name=value | |
authentication_ldap_sasl_auth_method_name | |
SCRAM-SHA-1 |
SCRAM-SHA-1
authentication_ldap_sasl_client
authentication_ldap_sasl_bind_base_dn
--authentication-ldap-sasl-bind-base-dn=value | |
authentication_ldap_sasl_bind_base_dn | |
NULL |
uid=user_name,pwd=user_password,ou=People,dc=example,dc=com
uid=user_name,pwd=user_password,ou=Admin,dc=example,dc=com
ou=People,dc=example,dc=com
ou=Admin,dc=example,dc=com
ou=dc=example,dc=com
authentication_ldap_sasl_bind_root_dn
--authentication-ldap-sasl-bind-root-dn=value | |
authentication_ldap_sasl_bind_root_dn | |
NULL |
authentication_ldap_sasl_bind_root_pwd
authentication_ldap_saslauthentication_ldap_sasl_bind_root_dnauthentication_ldap_sasl_bind_root_pwd
authentication_ldap_sasl
authentication_ldap_sasl_bind_root_pwd
--authentication-ldap-sasl-bind-root-pwd=value | |
authentication_ldap_sasl_bind_root_pwd | |
NULL |
authentication_ldap_sasl_bind_root_dn
authentication_ldap_sasl_ca_path
--authentication-ldap-sasl-ca-path=value | |
authentication_ldap_sasl_ca_path | |
NULL |
authentication_ldap_sasl_ca_pathauthentication_ldap_sasl_tls
authentication_ldap_sasl_group_search_attr
--authentication-ldap-sasl-group-search-attr=value | |
authentication_ldap_sasl_group_search_attr | |
cn |
authentication_ldap_sasl_group_search_attrcnuser1mygroupmygroup
isMemberOfisMemberOfmember
authentication_ldap_sasl_group_search_filter
--authentication-ldap-sasl-group-search-filter=value | |
authentication_ldap_sasl_group_search_filter | |
(|(&(objectClass=posixGroup)(memberUid=%s))(&(objectClass=group)(member=%s))) |
{UA}{UA}{UD}"uid=admin,ou=People,dc=example,dc=com"
(|(&(objectClass=posixGroup)(memberUid={UA}))
(&(objectClass=group)(member={UD})))
memberOf{GA}MemberOf
authentication_ldap_sasl_init_pool_size
--authentication-ldap-sasl-init-pool-size=value | |
authentication_ldap_sasl_init_pool_size | |
10 | |
0 | |
32767 |
authentication_ldap_sasl_init_pool_sizeauthentication_ldap_sasl_max_pool_size
authentication_ldap_sasl_init_pool_sizeauthentication_ldap_sasl_max_pool_size=0
authentication_ldap_sasl_max_pool_size
authentication_ldap_sasl_max_pool_size=0
authentication_ldap_sasl_log_status
--authentication-ldap-sasl-log-status=value | |
authentication_ldap_sasl_log_status | |
1 | |
1 | |
5 |
AUTHENTICATION_LDAP_CLIENT_LOGauthentication_ldap_sasl_log_status
AUTHENTICATION_LDAP_CLIENT_LOG
authentication_ldap_sasl_max_pool_size
--authentication-ldap-sasl-max-pool-size=value | |
authentication_ldap_sasl_max_pool_size | |
1000 | |
0 | |
32767 |
authentication_ldap_sasl_init_pool_size
authentication_ldap_sasl_server_host
--authentication-ldap-sasl-server-host=value | |
authentication_ldap_sasl_server_host | |
authentication_ldap_sasl_auth_method_name=SCRAM-SHA-1
authentication_ldap_sasl_server_port
--authentication-ldap-sasl-server-port=value | |
authentication_ldap_sasl_server_port | |
389 | |
1 | |
32376 |
--authentication-ldap-sasl-tls=value | |
authentication_ldap_sasl_tls | |
OFF |
authentication_ldap_sasl_ca_path
ldaps
authentication_ldap_sasl_user_search_attr
--authentication-ldap-sasl-user-search-attr=value | |
authentication_ldap_sasl_user_search_attr | |
uid |
authentication_ldap_sasl_user_search_attruser1user1
authentication_ldap_simple_auth_method_name
--authentication-ldap-simple-auth-method-name=value | |
authentication_ldap_simple_auth_method_name | |
SIMPLE |
SIMPLEauthentication_ldap_simple_bind_root_dn
AD-FOREST
authentication_ldap_simple_bind_base_dn
--authentication-ldap-simple-bind-base-dn=value | |
authentication_ldap_simple_bind_base_dn | |
NULL |
uid=user_name,pwd=user_password,ou=People,dc=example,dc=com
uid=user_name,pwd=user_password,ou=Admin,dc=example,dc=com
ou=People,dc=example,dc=com
ou=Admin,dc=example,dc=com
ou=dc=example,dc=com
authentication_ldap_simple_bind_root_dn
--authentication-ldap-simple-bind-root-dn=value | |
authentication_ldap_simple_bind_root_dn | |
NULL |
authentication_ldap_simple_bind_root_pwd
authentication_ldap_simpleauthentication_ldap_simple_bind_root_dnauthentication_ldap_simple_bind_root_pwd
authentication_ldap_simple
authentication_ldap_simple_bind_root_pwd
--authentication-ldap-simple-bind-root-pwd=value | |
authentication_ldap_simple_bind_root_pwd | |
NULL |
authentication_ldap_simple_bind_root_dn
authentication_ldap_simple_ca_path
--authentication-ldap-simple-ca-path=value | |
authentication_ldap_simple_ca_path | |
NULL |
authentication_ldap_simple_ca_pathauthentication_ldap_simple_tls
authentication_ldap_simple_group_search_attr
--authentication-ldap-simple-group-search-attr=value | |
authentication_ldap_simple_group_search_attr | |
cn |
authentication_ldap_simple_group_search_attrcnuser1mygroupmygroup
isMemberOfisMemberOfmember
authentication_ldap_simple_group_search_filter
--authentication-ldap-simple-group-search-filter=value | |
authentication_ldap_simple_group_search_filter | |
(|(&(objectClass=posixGroup)(memberUid=%s))(&(objectClass=group)(member=%s))) |
{UA}{UA}{UD}"uid=admin,ou=People,dc=example,dc=com"
(|(&(objectClass=posixGroup)(memberUid={UA}))
(&(objectClass=group)(member={UD})))
memberOf{GA}MemberOf
authentication_ldap_simple_init_pool_size
--authentication-ldap-simple-init-pool-size=value | |
authentication_ldap_simple_init_pool_size | |
10 | |
0 | |
32767 |
authentication_ldap_simple_init_pool_sizeauthentication_ldap_simple_max_pool_size
authentication_ldap_simple_init_pool_sizeauthentication_ldap_simple_max_pool_size=0
authentication_ldap_simple_max_pool_size
authentication_ldap_simple_max_pool_size=0
authentication_ldap_simple_log_status
--authentication-ldap-simple-log-status=value | |
authentication_ldap_simple_log_status | |
1 | |
1 | |
5 |
authentication_ldap_simple_max_pool_size
--authentication-ldap-simple-max-pool-size=value | |
authentication_ldap_simple_max_pool_size | |
1000 | |
0 | |
32767 |
authentication_ldap_simple_init_pool_size
authentication_ldap_simple_server_host
--authentication-ldap-simple-server-host=value | |
authentication_ldap_simple_server_host | |
authentication_ldap_simple_auth_method_name=SIMPLE
authentication_ldap_simple_auth_method_name=AD-FORESTmem.local
10.172.166.100
ldap1.mem.local10.172.166.101
host -t SRV _ldap._tcp.mem.local
/etc/resolv.conf
10.172.166.100域名
_ldap._tcp.mem.local. 86400 IN SRV 0 100 389 ldap1.mem.local. _ldap._tcp.mem.local. 86400 IN SRV 0 100 389 ldap2.mem.local. _ldap._tcp.mem.local. 86400 IN SRV 0 100 389 ldap3.mem.local.
/etc/hosts
10.172.166.101 ldap1.mem.local10.172.166.102 ldap2.mem.local10.172.166.103 ldap3.mem.local
authentication_ldap_simple_server_host
authentication_ldap_simple_server_port
--authentication-ldap-simple-server-port=value | |
authentication_ldap_simple_server_port | |
389 | |
1 | |
32376 |
authentication_ldap_simple_tls
--authentication-ldap-simple-tls=value | |
authentication_ldap_simple_tls | |
OFF |
authentication_ldap_simple_ca_path
ldaps
authentication_ldap_simple_user_search_attr
--authentication-ldap-simple-user-search-attr=value | |
authentication_ldap_simple_user_search_attr | |
uid |
authentication_ldap_simple_user_search_attruser1user1
CONNECTION_CONTROL
CONNECTION_CONTROLMYSQL_AUDIT_CONNECTION_CLASSMASKMYSQL_AUDIT_CONNECTION_CHANGE_USER
CONNECTION_CONTROL_FAILED_LOGIN_ATTEMPTS
CONNECTION_CONTROL_FAILED_LOGIN_ATTEMPTS
CONNECTION_CONTROL
plugin_dirplugin_dir
connection_control.dll
--plugin-load-add.so
[mysqld]plugin-load-add=connection_control.so
my.cnf
.so
安装插件_ connection连接控制soname _ control.so插件连接;安装_调控_ failed _登录连接_ control.so soname _势力;
INSTALL PLUGIN
INFORMATION_SCHEMA.PLUGINSSHOW PLUGINS
mysql>SELECT PLUGIN_NAME, PLUGIN_STATUSFROM INFORMATION_SCHEMA.PLUGINSWHERE PLUGIN_NAME LIKE 'connection%';+------------------------------------------+---------------+ | PLUGIN_NAME | PLUGIN_STATUS | +------------------------------------------+---------------+ | CONNECTION_CONTROL | ACTIVE | | CONNECTION_CONTROL_FAILED_LOGIN_ATTEMPTS | ACTIVE | +------------------------------------------+---------------+
INSTALL PLUGIN--plugin-load-add--connection-control-failed-login-attempts
[mysqld]plugin-load-add=connection_control.soconnection-control=FORCE_PLUS_PERMANENTconnection-control-failed-login-attempts=FORCE_PLUS_PERMANENT
FORCE
CONNECTION_CONTROL_FAILED_LOGIN_ATTEMPTSCONNECTION_CONTROL_FAILED_LOGIN_ATTEMPTS
CONNECTION_CONTROL
connection_control_failed_connections_threshold
connection_control_min_connection_delay
connection_control_failed_connections_thresholdconnection_control_failed_connections_thresholdconnection_control_min_connection_delayconnection_control_failed_connections_thresholdconnection_control_min_connection_delayconnection_control_max_connection_delay
CONNECTION_CONTROL
[mysqld] plugin-load-add=connection_control.so connection_control_failed_connections_threshold=4 connection_control_min_connection_delay=1500
SET PERSIST connection_control_failed_connections_threshold = 4; SET PERSIST connection_control_min_connection_delay = 1500;
SET
PERSISTGLOBAL
connection_control_min_connection_delayconnection_control_max_connection_delay
connection_control_min_connection_delayconnection_control_max_connection_delayconnection_control_max_connection_delayconnection_control_min_connection_delay
CONNECTION_CONTROL
external_user@example.comexternal_user@example.comexternal_user@example.commysql.user
mysql.userCURRENT_USER()host1.example.comuser1@host1.example.comuser1@%.comuser1@%.example.comuser1@%
mysql.user
mysql.userCURRENT_USER()host2.example.com
mysql.user
错误1130(hy000):主机 host_name“不允许连接到MySQL服务器
CONNECTION_CONTROL
Connection_control_delay_generatedconnection_control_failed_connections_threshold
INFORMATION_SCHEMACONNECTION_CONTROL_FAILED_LOGIN_ATTEMPTS
connection_control_failed_connections_threshold
CONNECTION_CONTROL
CONNECTION_CONTROL
connection_control_failed_connections_threshold
--connection-control-failed-connections-threshold=# | |
connection_control_failed_connections_threshold | |
3 | |
0 | |
2147483647 |
NN
connection_control_failed_connections_threshold
connection_control_max_connection_delay
--connection-control-max-connection-delay=# | |
connection_control_max_connection_delay | |
2147483647 | |
1000 | |
2147483647 |
connection_control_failed_connections_threshold
connection_control_max_connection_delay
connection_control_min_connection_delay
--connection-control-min-connection-delay=# | |
connection_control_min_connection_delay | |
1000 | |
1000 | |
2147483647 |
connection_control_failed_connections_threshold
connection_control_min_connection_delay
CONNECTION_CONTROL
Connection_control_delay_generated
connection_control_failed_connections_threshold
INFORMATION_SCHEMACONNECTION_CONTROL_FAILED_LOGIN_ATTEMPTS
connection_control_failed_connections_thresholdConnection_control_delay_generated
validate_password
validate_password
validate_password
validate_password
ER_NOT_VALID_PASSWORDALTER USERCREATE USERGRANTSET PASSWORD
VALIDATE_PASSWORD_STRENGTH()
validate_password
mysql> ALTER USER USER() IDENTIFIED BY 'abc';
ERROR 1819 (HY000): Your password does not satisfy the current
policy requirements
mysql>ALTER USER 'jeffrey'@'localhost'IDENTIFIED WITH mysql_native_passwordAS '*0D3CED9BEC10A777AEC23CCC353A8C08A633045E';Query OK, 0 rows affected (0.01 sec)
validate_password.xxx
validate_passwordxxxVALIDATE_PASSWORD_STRENGTH()
validate_passwordMEDIUMMEDIUMvalidate_password.policy
LOWvalidate_password.length
MEDIUMvalidate_password.number_countvalidate_password.mixed_case_countvalidate_password.special_char_count
STRONGvalidate_password.dictionary_file
validate_passwordvalidate_password.check_user_name
validate_password
validate_password
validate_passwordvalidate_password
plugin_dirplugin_dir
validate_password
安装组件:组件文件_ _密码/验证;
INSTALL
COMPONENT
validate_password
“文件/卸载组件:组件_ _密码验证;
UNINSTALL COMPONENT
validate_password
validate_password
MySQL的> SHOW VARIABLES LIKE 'validate_password.%';Password.Polic.Polic.Polic.Inflic.Policy Controll Action Palestate Action Car Passord.Expert Car Car Car Co Car Co Car Co Co Co Co Co Co Co Co Co CA 1 DIN DOU CA 1 DOM CUR CA 1 DIN DOR ADOR ADOR
validate_password.check_user_name
--validate-password.check-user-name | |
validate_password.check_user_name | |
ON |
validate_password
validate_password.check_user_namevalidate_password.policy
validate_password.check_user_name
validate_passwordALTER USERSET PASSWORDVALIDATE_PASSWORD_STRENGTH()
USER()CURRENT_USER()'jeffrey'@'localhost''root
USER()CURRENT_USER()
VALIDATE_PASSWORD_STRENGTH()
validate_password.dictionary_file
validate_password.dictionary_file | |
validate_password
utf8
STRONGvalidate_password.policy
VALIDATE_PASSWORD_STRENGTH()validate_password.policy
validate_password.dictionary_file
validate_password.length | |
8 | |
0 |
validate_password
validate_password.length
_计数验证验证_ password.number _ password.special _ char count(2×_案例验证_ password.mixed _ _ count)
validate_passwordvalidate_password.length
validate_password.mixed_case_count
validate_password.mixed_case_count | |
1 | |
0 |
validate_passwordvalidate_password
validate_password.mixed_case_count
validate_password.number_count
validate_password.number_count | |
1 | |
0 |
validate_passwordvalidate_password
validate_password.policy | |
1 | |
|
validate_password
validate_password.policyvalidate_password.check_user_name
validate_password.policyMEDIUMvalidate_password.lengthxxx
0 | |
1 | |
2 |
validate_password.special_char_count
validate_password.special_char_count | |
1 | |
0 |
validate_passwordvalidate_password
validate_password
MySQL的> SHOW STATUS LIKE 'validate_password.%';----------------------------------------------- _ name变量值|最最| | ----------------------------------------------- |验证文件_ password.dictionary _ _ | 2018年最后_解析:1999-01-15 08 33:49 | |验证文件的话_ password.dictionary _ _ _ count | 1902年| ----------------------------------------------- ---------------------
validate_password.dictionary_file_last_parsed
validate_password
validate_password.dictionary_file_words_count
validate_password
validate_passwordvalidate_password
validate_password
--validate-password[=value] | |
ON | |
|
validate_password--validate-password=FORCE_PLUS_PERMANENT
validate_passwordINSTALL
PLUGIN--plugin-load-add
validate_passwordvalidate_password
validate_password_check_user_name
--validate-password-check-user-name | |
validate_password_check_user_name | |
ON |
validate_passwordvalidate_password.check_user_name
validate_password_dictionary_file
validate_password_dictionary_file | |
validate_passwordvalidate_password.dictionary_file
validate_password_length | |
8 | |
0 |
validate_passwordvalidate_password.length
validate_password_mixed_case_count
validate_password_mixed_case_count | |
1 | |
0 |
validate_passwordvalidate_password.mixed_case_count
validate_password_number_count
validate_password_number_count | |
1 | |
0 |
validate_passwordvalidate_password.number_count
validate_password_policy | |
1 | |
|
validate_passwordvalidate_password.policy
validate_password_special_char_count
validate_password_special_char_count | |
1 | |
0 |
validate_passwordvalidate_password.special_char_count
validate_passwordvalidate_password
validate_password_dictionary_file_last_parsed
validate_passwordvalidate_password.dictionary_file_last_parsed
validate_password_dictionary_file_words_count
validate_passwordvalidate_password.dictionary_file_words_count
validate_passwordvalidate_password
validate_password
validate_password
安装组件:组件文件_ _密码/验证;
validate_passwordxxx
[mysqld] validate-password=FORCE_PLUS_PERMANENT validate_password_dictionary_file=/usr/share/dict/words validate_password_length=10 validate_password_number_count=2
--validate-password
[mysqld]validate_password.dictionary_file=/usr/share/dict/wordsvalidate_password.length=10validate_password.number_count=2
validate_password
validate_password
validate_password卸载插件;
validate_password--plugin-load--plugin-load-add
keyring_file
keyring_encrypted_file
keyring_okv
keyring_aws
keyring_file
InnoDB
keyring_file
keyring_encrypted_file
keyring_okv
keyring_aws
plugin_dirplugin_dir
keyring_file
keyring_file.so
InnoDB
--early-plugin-loadmy.cnf
[mysqld] early-plugin-load=keyring_file.so
keyring_file
keyring_okv
keyring_aws
INFORMATION_SCHEMA.PLUGINSSHOW PLUGINS
mysql>SELECT PLUGIN_NAME, PLUGIN_STATUSFROM INFORMATION_SCHEMA.PLUGINSWHERE PLUGIN_NAME LIKE 'keyring%';+--------------+---------------+ | PLUGIN_NAME | PLUGIN_STATUS | +--------------+---------------+ | keyring_file | ACTIVE | +--------------+---------------+
InnoDBInnoDB--early-plugin-load
--plugin-load--plugin-load-addINSTALL PLUGIN
--plugin-load--plugin-load-add
INSTALL
PLUGINmysql.pluginInnoDB
keyring_file
keyring_file
keyring_filekeyring_file
keyring_file--early-plugin-loadkeyring_file_datamy.cnf
[mysqld] early-plugin-load=keyring_file.so keyring_file_data=/usr/local/mysql/mysql-keyring/keyring
keyring_filekeyring_file_data
keyring_file_data
keyring_file
keyring_file
SELECT keyring_key_generate('MyKey', 'AES', 32);
SELECT keyring_key_remove('MyKey');
keyring_file
keyring_encrypted_file
keyring_encrypted_file
keyring_encrypted_file
keyring_encrypted_filekeyring_encrypted_file
keyring_encrypted_file--early-plugin-loadkeyring_encrypted_file_passwordkeyring_encrypted_file_datamy.cnf
[mysqld]
early-plugin-load=keyring_encrypted_file.so
keyring_encrypted_file_data=/usr/local/mysql/mysql-keyring/keyring-encrypted
keyring_encrypted_file_password=password
my.cnf
keyring_encrypted_filekeyring_encrypted_file_data
keyring_encrypted_file
keyring_encrypted_file
keyring_encrypted_file
SELECT keyring_key_generate('MyKey', 'AES', 32);
SELECT keyring_key_remove('MyKey');
keyring_encrypted_file
keyring_okv
keyring_okv
keyring_okv
SELECT keyring_key_generate('MyKey', 'AES', 32);
SELECT keyring_key_remove('MyKey');
keyring_okv
keyring_okvkeyring_okv
keyring_okvkeyring_okv_conf_dirkeyring_okv
[警告]插件keyring_okv报道:“keyring_okv到beinitialized,请点keyring_okv_conf_dir变量一个directorycontaining Oracle密钥库的配置文件和SSL的材料
keyring_okv_conf_dir
okvclient.ora
sslcert.pemssl
okvclient.orakeyring_okv
keyring_okvroot
cd /usr/local mysqlmkdir MySQL的钥匙圈okvchmod 750 MySQL的钥匙圈okvchown mysql mysql的钥匙圈钥匙圈okvchgrp OKV
keyring_okv--early-plugin-loadkeyring_okv_conf_dirmy.cnf
[mysqld] early-plugin-load=keyring_okv.so keyring_okv_conf_dir=/usr/local/mysql/mysql-keyring-okv
keyring_okv
keyring_okv
okvclient.jar
keyring_okv
keyring_okv
keyring_okv_conf_dir
okvclient.jar
okvclient.jar
okvclient.jar JAR(Java dir_name[五]
-d
okvclient.ora
install_dir/conf/okvclient.ora
SERVER=host_ip:port_numSTANDBY_SERVER=host_ip:port_num
keyring_okvSTANDBY_SERVER
SERVER
STANDBY_SERVER
okvutil/bin/okvutil list
Unique ID Type Identifier 255AB8DE-C97F-482C-E053-0100007F28B9 Symmetric Key - 264BF6E0-A20E-7C42-E053-0100007FB29C Symmetric Key -
no objects found
ssl
jar xf okvclient.jar ssl
okvclient.ora
keyring_okv
keyring_okv
keyring_okv
keyring_okv_conf_dir
ssl
okvclient.ora
SERVER=host_ip: port_numSTANDBY_SERVER=host_ip: port_num
okvclient.ora
SERVER=198.51.100.20:9002STANDBY_SERVER=198.51.100.20:9002
Navigate to Security >> Local CAs and create a local certificate authority (CA).
ssl
Navigate to Security >> Certificate Requests and create a certificate. Then you will be able to download a compressed
csr_w_pk_pkcs8.gz
焦油zxvf CSR _ W _ _ pkcs8.gz PK
certificate_request.pem
key.pem
OpenSSL pkcs8 - private_key_pkcs8.pem出key.pem
key.pem
certificate_request.pem
Navigate to Security >> Local CAs. Select the same CA that you created earlier (the one you downloaded to create theCA.pem
cert.pem
keyring_okv
ssl
key.pem
内核> openssl rsa -des3 -in key.pem -out key.pem.new输入:输入阶段质子交换膜燃料电池质子交换膜检验通通段:
password.txt
shell> openssl rsa -in key.pem.new -passin file:password.txt
key.pemkey.pem
key.pemssl
keyring_aws
keyring_aws
keyring_aws
keyring_aws
keyring_aws
keyring_awskeyring_aws_rotate_keys()
keyring_aws
keyring_aws_cmk_idSET
GLOBAL
/usr/local/mysql/mysql-keyring/keyring_aws_conf
shell>cd /usr/local/mysqlshell>mkdir mysql-keyringshell>chmod 750 mysql-keyringshell>chown mysql mysql-keyringshell>chgrp mysql mysql-keyring
keyring_aws_conf_file
keyring_aws
wwwwwwwwwwwwwEXAMPLE
wwwwwwwwwwwwwEXAMPLE xxxxxxxxxxxxx/yyyyyyy/zzzzzzzzEXAMPLEKEY
keyring_aws--early-plugin-loadkeyring_aws_cmk_idkeyring_aws_conf_filekeyring_aws_data_filemy.cnf
[mysqld] early-plugin-load=keyring_aws.so keyring_aws_cmk_id='arn:aws:kms:us-west-2:111122223333:key/abcd1234-ef56-ab12-cd34-ef56abcd1234' keyring_aws_conf_file=/usr/local/mysql/mysql-keyring/keyring_aws_conf keyring_aws_data_file=/usr/local/mysql/mysql-keyring/keyring_aws_data
keyring_aws
keyring_aws
keyring_aws
CREATE FUNCTION keyring_aws_rotate_cmk RETURNS INTEGER SONAME 'keyring_aws.so'; CREATE FUNCTION keyring_aws_rotate_keys RETURNS INTEGER SONAME 'keyring_aws.so';
keyring_aws
keyring_aws
keyring_aws
keyring_aws
SELECT keyring_key_generate('MyKey', 'AES', 32);
SELECT keyring_key_remove('MyKey');
keyring_aws_rotate_cmk()
keyring_aws
keyring_aws
keyring_aws_conf_file
keyring_aws
.so
卸载插件keyring_aws;安装插件keyring_aws现在的keyring_aws。”;
INSTALL PLUGINkeyring_aws--early-plugin-load
UNINSTALL PLUGININSTALL PLUGINUNINSTALL
PLUGIN--early-plugin-load
root
--keyring-migration-source
--keyring-migration-destination
--keyring-migration-host
--keyring-migration-user--keyring-migration-password
--keyring-migration-port
--keyring-migration-socket
keyring_filekeyring_file_data--defaults-file
mysqlisabelisabel
root--user=user_nameuser_name
mysqld --defaults-file=/usr/local/mysql/etc/my.cnf
--keyring-migration-source=keyring_file.so
--keyring-migration-destination=keyring_encrypted_file.so
--keyring_encrypted_file_password=password
mysqld --defaults-file=/usr/local/mysql/etc/my.cnf --keyring-migration-source=keyring_file.so --keyring-migration-destination=keyring_encrypted_file.so --keyring_encrypted_file_password=password--keyring-migration-host=localhost --keyring-migration-user=root --keyring-migration-password=root_password
keyring_operationsENCRYPTION_KEY_ADMINSYSTEM_VARIABLES_ADMINSUPER
keyring_operationskeyring_operations
keyring_operations
keyring_operationskeyring_operationskeyring_operations
keyring_operations=OFF
keyring_operations=ON
keyring_operations=ON
keyring_encrypted_file |
| |
keyring_file |
| |
keyring_okv | AES | |
keyring_aws | AES |
keyring_udfkeyring_okv
keyring_udf
keyring_udf
plugin_dirplugin_dir
keyring_udf.dll
keyring_udfINSTALL PLUGINCREATE FUNCTION
INSTALL PLUGIN keyring_udf SONAME 'keyring_udf.so'; CREATE FUNCTION keyring_key_generate RETURNS INTEGER SONAME 'keyring_udf.so'; CREATE FUNCTION keyring_key_fetch RETURNS STRING SONAME 'keyring_udf.so'; CREATE FUNCTION keyring_key_length_fetch RETURNS INTEGER SONAME 'keyring_udf.so'; CREATE FUNCTION keyring_key_type_fetch RETURNS STRING SONAME 'keyring_udf.so'; CREATE FUNCTION keyring_key_store RETURNS INTEGER SONAME 'keyring_udf.so'; CREATE FUNCTION keyring_key_remove RETURNS INTEGER SONAME 'keyring_udf.so';
keyring_udfUNINSTALL PLUGINDROP FUNCTION
卸载插件keyring_udf;降功能keyring_key_generate;降功能keyring_key_fetch;降功能keyring_key_length_fetch;降功能keyring_key_type_fetch;降功能keyring_key_store;降功能keyring_key_remove;
keyring_udf
错误1123(hy000):无法初始化函数keyring_key_generate’;此功能需要keyring_udf插件没有安装,请安装
keyring_udf
keyring_file
ERROR 3188 (HY000): Function 'keyring_key_generate' failed because underlying keyring service returned an error. Please check if a keyring plugin is installed and that provided arguments are valid for the keyring you are using.
EXECUTE
错误1123(hy000):无法初始化函数keyring_key_generate”;用户不能执行此功能。用户需要有执行
EXECUTE
授予执行*。* user;
EXECUTE
CURRENT_USER()
keyring_key_generate()
mysql> SELECT keyring_key_generate('MyKey', 'DSA', 256);
+-------------------------------------------+
| keyring_key_generate('MyKey', 'DSA', 256) |
+-------------------------------------------+
| 1 |
+-------------------------------------------+
NULL
SELECT ... INTO
@var_name
MySQL的> SELECT keyring_key_generate('', '', -1) INTO @x;错误3188(hy000):功能keyring_key_generate失败becauseunderlying钥匙服务返回一个错误。请检查是否akeyring插件安装,设置参数适用于您正在使用的钥匙圈。MySQL > SELECT @x;| ------“零X | ------ | | MySQL >。 SELECT keyring_key_generate('x', 'AES', 16) INTO @x;MySQL的> SELECT @x;------ | @ x | | 1 |??????
keyring_key_generate()
MySQL的> SELECT keyring_key_type_fetch('MyKey');--------------------------------- | keyring_key_type_fetch('mykey”)| --------------------------------- | DSA | --------------------------------- MySQL > SELECT keyring_key_length_fetch('MyKey');----------------------------------- | keyring_key_length_fetch('mykey”)| ----------------------------------- | 256 | -----------------------------------
keyring_key_fetch()HEX()
MySQL的> SELECT keyring_key_generate('MyShortKey', 'DSA', 8);---------------------------------------------- | keyring_key_generate('myshortkey '、' DSA,8)| ---------------------------------------------- | 1 | ---------------------------------------------- MySQL > SELECT HEX(keyring_key_fetch('MyShortKey'));-------------------------------------- | hex(keyring_key_fetch('myshortkey '))| -------------------------------------- | 1db3b0fc3328a24c | --------------------------------------
MyKey
keyring_key_remove()
MySQL的> SELECT keyring_key_remove('MyKey');----------------------------- | keyring_key_remove('mykey”)| ----------------------------- | 1 | -----------------------------
keyring_key_store()
MySQL的> SELECT keyring_key_store('AES_key', 'AES', 'Secret string');| keyring _ ------------------------------------------------------(key _商店_ AES AES密钥,秘密,柱| ------------------------------------------------------ |)1 | ------------------------------------------------------
EXECUTECURRENT_USER()EXECUTE
DEFINER
EXECUTE
DEFINER
SharedKeyEXECUTE
'root'@'localhost'
MySQL的> CREATE SCHEMA key_schema;MySQL的> CREATE DEFINER = 'root'@'localhost'FUNCTION key_schema.get_shared_key()RETURNS BLOB READS SQL DATARETURN keyring_key_fetch('SharedKey');
mysql> SELECT keyring_key_generate('SharedKey', 'DSA', 8);
+---------------------------------------------+
| keyring_key_generate('SharedKey', 'DSA', 8) |
+---------------------------------------------+
| 1 |
+---------------------------------------------+
mysql>CREATE USER 'key_user'@'localhost'IDENTIFIED BY 'key_user_pwd';
key_userEXECUTE
MySQL的> SELECT HEX(key_schema.get_shared_key());错误1370(42000):执行命令拒绝用户key_user”@ 'localhost'for常规的key_schema get_shared_key”。
EXECUTE
mysql>GRANT EXECUTE ON FUNCTION key_schema.get_shared_keyTO 'key_user'@'localhost';
key_user
MySQL的> SELECT HEX(key_schema.get_shared_key());---------------------------------- | hex(key_schema。get_shared_key())| ---------------------------------- | 9bafb9e75ceeb013 | ----------------------------------
keyring_key_fetch()
STRING keyring_key_fetch(STRING key_id)
key_id
NULL
keyring_key_fetch()keyring_key_fetch()
mysql>SELECT keyring_key_generate('RSA_key', 'RSA', 16);+--------------------------------------------+ | keyring_key_generate('RSA_key', 'RSA', 16) | +--------------------------------------------+ | 1 | +--------------------------------------------+ mysql>SELECT HEX(keyring_key_fetch('RSA_key'));+-----------------------------------+ | HEX(keyring_key_fetch('RSA_key')) | +-----------------------------------+ | 91C2253B696064D3556984B6630F891A | +-----------------------------------+ mysql>SELECT keyring_key_type_fetch('RSA_key');+-----------------------------------+ | keyring_key_type_fetch('RSA_key') | +-----------------------------------+ | RSA | +-----------------------------------+ mysql>SELECT keyring_key_length_fetch('RSA_key');+-------------------------------------+ | keyring_key_length_fetch('RSA_key') | +-------------------------------------+ | 16 | +-------------------------------------+
HEX()
keyring_key_generate()
STRING keyring_key_generate(STRING key_id, STRING key_type, INTEGER key_length)
key_id
key_type
key_length
NULL
mysql> SELECT keyring_key_generate('RSA_key', 'RSA', 384);
+---------------------------------------------+
| keyring_key_generate('RSA_key', 'RSA', 384) |
+---------------------------------------------+
| 1 |
+---------------------------------------------+
keyring_key_length_fetch()
INTEGER keyring_key_length_fetch(STRING key_id)
key_id
NULL
keyring_key_fetch()
keyring_key_remove()
INTEGER keyring_key_remove(STRING key_id)
key_id
NULL
mysql> SELECT keyring_key_remove('AES_key');
+-------------------------------+
| keyring_key_remove('AES_key') |
+-------------------------------+
| 1 |
+-------------------------------+
keyring_key_store()
INTEGER keyring_key_store(STRING key_id, STRING key_type, STRING key)
key_id
key_type
key
NULL
mysql> SELECT keyring_key_store('new key', 'DSA', 'My key value');
+-----------------------------------------------------+
| keyring_key_store('new key', 'DSA', 'My key value') |
+-----------------------------------------------------+
| 1 |
+-----------------------------------------------------+
keyring_key_type_fetch()
STRING keyring_key_type_fetch(STRING key_id)
key_id
NULL
keyring_key_fetch()
keyring_aws_rotate_cmk()
keyring_awsSUPER
keyring_aws_rotate_cmk()
keyring_aws_cmk_id
INTEGER keyring_aws_rotate_cmk()
NULL
keyring_aws_rotate_keys()
keyring_awsSUPER
keyring_aws_rotate_keys()keyring_aws_data_filekeyring_aws_cmk_id
keyring_aws_rotate_keys()
keyring_aws_rotate_cmk()
keyring_aws_cmk_id
INTEGER keyring_aws_rotate_keys()
NULL
--keyring-migration-destination=plugin
--keyring-migration-destination=plugin_name | |
--keyring-migration-source
--keyring-migration-source--keyring-migration-destination
--keyring-migration-host=host_name
--keyring-migration-host=host_name | |
localhost |
localhost::1
--keyring-migration-password[=password]
--keyring-migration-password[=password] | |
password
--keyring-migration-port=port_num
--keyring-migration-port=port_num | |
3306 |
--keyring-migration-socket=path
--keyring-migration-socket={file_name|pipe_name} | |
--keyring-migration-source=plugin
--keyring-migration-source=plugin_name | |
--plugin-loadname=plugin_libraryplugin_librarynameplugin_libraryplugin_dir
--keyring-migration-source--keyring-migration-destination
--keyring-migration-user=user_name
--keyring-migration-user=user_name | |
--keyring-aws-cmk-id | |
keyring_aws_cmk_id | |
keyring_aws
--keyring-aws-conf-file | |
keyring_aws_conf_file | |
platform specific |
keyring_aws
keyring_aws
keyring_aws_confkeyring_file_data
--keyring-aws-data-file | |
keyring_aws_data_file | |
platform specific |
keyring_aws
keyring_aws_data_filekeyring_aws
keyring_aws_datakeyring_file_data
--keyring-aws-region | |
keyring_aws_region | |
us-east-1 | |
|
--keyring-encrypted-file-data=file_name | |
keyring_encrypted_file_data | |
platform specific |
keyring_encrypted_file
keyring_encrypted_filekeyring_encrypted_file_data
keyring_encrypted_file
keyring_encryptedINSTALL_LAYOUTINSTALL_MYSQLKEYRINGDIR
INSTALL_LAYOUT | keyring_encrypted_file_data |
|---|---|
DEBSLES | /var/lib/mysql-keyring/keyring_encrypted |
keyring/keyring_encryptedCMAKE_INSTALL_PREFIX |
keyring_encrypted_file_data
/usr/local/mysql/mysql-keyring
cd /usr/local/mysql mkdir mysql-keyring chmod 750 mysql-keyring chown mysql mysql-keyring chgrp mysql mysql-keyring
keyring_encrypted_filekeyring_encrypted_file_data
keyring_encrypted_filekeyring_encrypted_file_data
keyring_encrypted_file_password
--keyring-encrypted-file-password=password | |
keyring_encrypted_file_password | |
keyring_encrypted_file
keyring_encrypted_file_password
SHOW VARIABLESglobal_variables
--keyring-file-data=file_name | |
keyring_file_data | |
platform specific |
keyring_file
keyring_filekeyring_file_data
keyring_file
keyringINSTALL_LAYOUTINSTALL_MYSQLKEYRINGDIR
INSTALL_LAYOUT | keyring_file_data |
|---|---|
DEBSLES | /var/lib/mysql-keyring/keyring |
keyring/keyringCMAKE_INSTALL_PREFIX |
keyring_file_data
/usr/local/mysql/mysql-keyring
cd /usr/local/mysql mkdir mysql-keyring chmod 750 mysql-keyring chown mysql mysql-keyring chgrp mysql mysql-keyring
keyring_filekeyring_file_data
keyring_fileInnoDBkeyring_file_data
--keyring-okv-conf-dir=dir_name | |
keyring_okv_conf_dir | |
empty string |
keyring_okv
keyring_okv_conf_dir
/usr/local/mysql/mysql-keyring-okv
cd /usr/local/mysql mkdir mysql-keyring-okv chmod 750 mysql-keyring-okv chown mysql mysql-keyring-okv chgrp mysql mysql-keyring-okv
keyring_okv_conf_dirkeyring_okv_conf_dir
keyring_operations | |
ON |
ENCRYPTION_KEY_ADMINSYSTEM_VARIABLES_ADMINSUPER
audit_log
audit.logaudit_log_file
audit_log_format
SELECT NAME FROM performance_schema.setup_instruments WHERE NAME LIKE '%/alog/%';
audit_log
mysql
AUDIT_ADMIN
audit_log
plugin_dirplugin_dir
share
audit_log_filter_win_install.sql
audit_log_filter_linux_install.sql
shell>mysql -u root -p < audit_log_filter_linux_install.sqlEnter password:(enter root password here)
USERaudit_log_userHost
ALTER TABLE mysql.audit_log_user DROP FOREIGN KEY audit_log_user_ibfk_1; ALTER TABLE mysql.audit_log_filter CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_ci; ALTER TABLE mysql.audit_log_user CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_as_ci; ALTER TABLE mysql.audit_log_user MODIFY COLUMN USER VARCHAR(32); ALTER TABLE mysql.audit_log_user ADD FOREIGN KEY (FILTERNAME) REFERENCES mysql.audit_log_filter(NAME);
INFORMATION_SCHEMA.PLUGINSSHOW PLUGINS
mysql>SELECT PLUGIN_NAME, PLUGIN_STATUSFROM INFORMATION_SCHEMA.PLUGINSWHERE PLUGIN_NAME LIKE 'audit%';+-------------+---------------+ | PLUGIN_NAME | PLUGIN_STATUS | +-------------+---------------+ | audit_log | ACTIVE | +-------------+---------------+
--audit-log
[mysqld] audit-log=FORCE_PLUS_PERMANENT
--audit-logFORCE_PLUS_PERMANENT
SELECT audit_log_filter_set_filter('log_all', '{ "filter": { "log": true } }');
SELECT audit_log_filter_set_user('%', 'log_all');
%
DROP TABLE IF EXISTS mysql.audit_log_filter; DROP TABLE IF EXISTS mysql.audit_log_user; UNINSTALL PLUGIN audit_log; DROP FUNCTION audit_log_filter_set_filter; DROP FUNCTION audit_log_filter_remove_filter; DROP FUNCTION audit_log_filter_set_user; DROP FUNCTION audit_log_filter_remove_user; DROP FUNCTION audit_log_filter_flush; DROP FUNCTION audit_log_encryption_password_get; DROP FUNCTION audit_log_encryption_password_set; DROP FUNCTION audit_log_read; DROP FUNCTION audit_log_read_bookmark;
audit.logaudit_log_file
LOAD DATA
INFILE
audit_log_format
audit_log_format=OLD
audit_log_format=NEW
audit_log_format=JSON
audit_log_format=OLD
<?xml version="1.0" encoding="gb3212"?><AUDIT> <AUDIT_RECORD TIMESTAMP="2017-10-16T14:25:00 UTC" RECORD_ID="1_2017-10-16T14:25:00" NAME="Audit" SERVER_ID="1" VERSION="1" STARTUP_OPTIONS="--port=3306" OS_VERSION="i686-Linux" MYSQL_VERSION="5.7.21-log"/> <AUDIT_RECORD TIMESTAMP="2017-10-16T14:25:24 UTC" RECORD_ID="2_2017-10-16T14:25:00" NAME="Connect" CONNECTION_ID="4" STATUS="0" STATUS_CODE="0" USER="root" OS_LOGIN="" HOST="localhost" IP="127.0.0.1" COMMAND_CLASS="connect" CONNECTION_TYPE="SSL/TLS" PRIV_USER="root" PROXY_USER="" DB="test"/>... <AUDIT_RECORD TIMESTAMP="2017-10-16T14:25:24 UTC" RECORD_ID="6_2017-10-16T14:25:00" NAME="Query" CONNECTION_ID="4" STATUS="0" STATUS_CODE="0" USER="root[root] @ localhost [127.0.0.1]" OS_LOGIN="" HOST="localhost" IP="127.0.0.1" COMMAND_CLASS="drop_table" SQLTEXT="DROP TABLE IF EXISTS t"/>... <AUDIT_RECORD TIMESTAMP="2017-10-16T14:25:24 UTC" RECORD_ID="8_2017-10-16T14:25:00" NAME="Quit" CONNECTION_ID="4" STATUS="0" STATUS_CODE="0" USER="root" OS_LOGIN="" HOST="localhost" IP="127.0.0.1" COMMAND_CLASS="connect" CONNECTION_TYPE="SSL/TLS"/> <AUDIT_RECORD TIMESTAMP="2017-10-16T14:25:32 UTC" RECORD_ID="12_2017-10-16T14:25:00" NAME="NoAudit" SERVER_ID="1"/></AUDIT>
<AUDIT><AUDIT_RECORD><AUDIT></AUDIT>
<AUDIT_RECORD>
<AUDIT_RECORD>
<AUDIT_RECORD>
<"<"?
#x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
<AUDIT_RECORD>
NAME
NAME="Query"
NAME
审计在审计开始,这可能是服务器启动timeconnect当一个客户端连接,也被称为记录查询的SQL语句(直接执行SQL语句)制备制备;其次是SQL语句的执行executeexecute;通常遵循prepareshutdown服务器shutdownquit当客户disconnectsnoaudit审计已关闭
AuditChange
userConnect OutCreate DBDebugDrop
DBFetchInit DBLong DataPingProcesslistQuitRegister SlaveSet optionSleepTable
Dump
"Audit"COM_xxx"Create DB"COM_CREATE_DB
RECORD_ID
SEQ_TIMESTAMPYYYY-MM-DDhh:mm:ss
RECORD_ID="12_2017-10-16T14:25:00"
TIMESTAMP
YYYY-MM-DDThh:mm:ss
UTC
TIMESTAMP="2017-10-16T14:25:32
UTC"
<AUDIT_RECORD>
COMMAND_CLASS
COMMAND_CLASS="drop_table"
statement/sql/xxxxxxselectDROP
TABLESELECT
选择替换(event_name,声明/ SQL / ',')是从performance_schema.events_statements_summary_global_by_event_namewhere event_name喜欢声明/ SQL / %是的名字;
CONNECTION_ID
CONNECTION_ID()
CONNECTION_ID="127"
CONNECTION_TYPE
TCP/IPSocketShared
Memory
CONNECTION_TYPE="SSL/TLS"
DB
DB="test"
HOST
HOST="localhost"
IP
IP="127.0.0.1"
MYSQL_VERSION
VERSION()version
MYSQL_VERSION="5.7.21-log"
OS_LOGIN
external_user
OS_LOGIN="jeffrey"
OS_VERSION
OS_VERSION="x86_64-Linux"
PRIV_USER
USER
PRIV_USER="jeffrey"
PROXY_USER
PROXY_USER="developer"
SERVER_ID
server_id
SERVER_ID="1"
SQLTEXT
SQLTEXT="DELETE FROM t1"
STARTUP_OPTIONS
STARTUP_OPTIONS="--port=3306
--log-output=FILE"
STATUS
mysql_errno()STATUS
STATUS="1051"
STATUS_CODE
STATUS_CODESTATUS_CODEmysql_errno()
STATUS_CODE="0"
USER
PRIV_USER
VERSION
VERSION="1"
audit_log_format=NEW
<?xml version="1.0" encoding="gb3212"?><AUDIT> <AUDIT_RECORD> <TIMESTAMP>2017-10-16T14:06:33 UTC</TIMESTAMP> <RECORD_ID>1_2017-10-16T14:06:33</RECORD_ID> <NAME>Audit</NAME> <SERVER_ID>1</SERVER_ID> <VERSION>1</VERSION> <STARTUP_OPTIONS>/usr/local/mysql/bin/mysqld --socket=/usr/local/mysql/mysql.sock --port=3306</STARTUP_OPTIONS> <OS_VERSION>i686-Linux</OS_VERSION> <MYSQL_VERSION>5.7.21-log</MYSQL_VERSION> </AUDIT_RECORD> <AUDIT_RECORD> <TIMESTAMP>2017-10-16T14:09:38 UTC</TIMESTAMP> <RECORD_ID>2_2017-10-16T14:06:33</RECORD_ID> <NAME>Connect</NAME> <CONNECTION_ID>5</CONNECTION_ID> <STATUS>0</STATUS> <STATUS_CODE>0</STATUS_CODE> <USER>root</USER> <OS_LOGIN/> <HOST>localhost</HOST> <IP>127.0.0.1</IP> <COMMAND_CLASS>connect</COMMAND_CLASS> <CONNECTION_TYPE>SSL/TLS</CONNECTION_TYPE> <PRIV_USER>root</PRIV_USER> <PROXY_USER/> <DB>test</DB> </AUDIT_RECORD>... <AUDIT_RECORD> <TIMESTAMP>2017-10-16T14:09:38 UTC</TIMESTAMP> <RECORD_ID>6_2017-10-16T14:06:33</RECORD_ID> <NAME>Query</NAME> <CONNECTION_ID>5</CONNECTION_ID> <STATUS>0</STATUS> <STATUS_CODE>0</STATUS_CODE> <USER>root[root] @ localhost [127.0.0.1]</USER> <OS_LOGIN/> <HOST>localhost</HOST> <IP>127.0.0.1</IP> <COMMAND_CLASS>drop_table</COMMAND_CLASS> <SQLTEXT>DROP TABLE IF EXISTS t</SQLTEXT> </AUDIT_RECORD>... <AUDIT_RECORD> <TIMESTAMP>2017-10-16T14:09:39 UTC</TIMESTAMP> <RECORD_ID>8_2017-10-16T14:06:33</RECORD_ID> <NAME>Quit</NAME> <CONNECTION_ID>5</CONNECTION_ID> <STATUS>0</STATUS> <STATUS_CODE>0</STATUS_CODE> <USER>root</USER> <OS_LOGIN/> <HOST>localhost</HOST> <IP>127.0.0.1</IP> <COMMAND_CLASS>connect</COMMAND_CLASS> <CONNECTION_TYPE>SSL/TLS</CONNECTION_TYPE> </AUDIT_RECORD>... <AUDIT_RECORD> <TIMESTAMP>2017-10-16T14:09:43 UTC</TIMESTAMP> <RECORD_ID>11_2017-10-16T14:06:33</RECORD_ID> <NAME>Quit</NAME> <CONNECTION_ID>6</CONNECTION_ID> <STATUS>0</STATUS> <STATUS_CODE>0</STATUS_CODE> <USER>root</USER> <OS_LOGIN/> <HOST>localhost</HOST> <IP>127.0.0.1</IP> <COMMAND_CLASS>connect</COMMAND_CLASS> <CONNECTION_TYPE>SSL/TLS</CONNECTION_TYPE> </AUDIT_RECORD> <AUDIT_RECORD> <TIMESTAMP>2017-10-16T14:09:45 UTC</TIMESTAMP> <RECORD_ID>12_2017-10-16T14:06:33</RECORD_ID> <NAME>NoAudit</NAME> <SERVER_ID>1</SERVER_ID> </AUDIT_RECORD></AUDIT>
<AUDIT><AUDIT_RECORD><AUDIT></AUDIT>
<AUDIT_RECORD>
<AUDIT_RECORD>
<AUDIT_RECORD>
<"<"?
#x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
<AUDIT_RECORD>
<NAME>
<NAME>Query</NAME>
<NAME>
审计在审计开始,这可能是服务器启动timeconnect当一个客户端连接,也被称为记录查询的SQL语句(直接执行SQL语句)制备制备;其次是SQL语句的执行executeexecute;通常遵循prepareshutdown服务器shutdownquit当客户disconnectsnoaudit审计已关闭
AuditChange
userConnect OutCreate DBDebugDrop
DBFetchInit DBLong DataPingProcesslistQuitRegister SlaveSet optionSleepTable
Dump
AuditCOM_xxxCreate DBCOM_CREATE_DB
<RECORD_ID>
SEQ_TIMESTAMPYYYY-MM-DDhh:mm:ss
<RECORD_ID>12_2017-10-16T14:06:33</RECORD_ID>
<TIMESTAMP>
YYYY-MM-DDThh:mm:ss
UTC<TIMESTAMP>
<TIMESTAMP>2017-10-16T14:09:45 UTC</TIMESTAMP>
<AUDIT_RECORD><NAME>
<COMMAND_CLASS>
<COMMAND_CLASS>drop_table</COMMAND_CLASS>
statement/sql/xxxxxxselectDROP
TABLESELECT
选择替换(event_name,声明/ SQL / ',')是从performance_schema.events_statements_summary_global_by_event_namewhere event_name喜欢声明/ SQL / %是的名字;
<CONNECTION_ID>
CONNECTION_ID()
<CONNECTION_ID>127</CONNECTION_ID>
<CONNECTION_TYPE>
TCP/IPSocketShared
Memory
<CONNECTION_TYPE>SSL/TLS</CONNECTION_TYPE>
<DB>
<DB>test</DB>
<HOST>
<HOST>localhost</HOST>
<IP>
<IP>127.0.0.1</IP>
<MYSQL_VERSION>
VERSION()version
<MYSQL_VERSION>5.7.21-log</MYSQL_VERSION>
<OS_LOGIN>
external_user
<OS_LOGIN>jeffrey</OS_LOGIN>
<OS_VERSION>
<OS_VERSION>x86_64-Linux</OS_VERSION>
<PRIV_USER>
<USER>
<PRIV_USER>jeffrey</PRIV_USER>
<PROXY_USER>
<PROXY_USER>developer</PROXY_USER>
<SERVER_ID>
server_id
<SERVER_ID>1</SERVER_ID>
<SQLTEXT>
<SQLTEXT>DELETE FROM t1</SQLTEXT>
<STARTUP_OPTIONS>
<STARTUP_OPTIONS>/usr/local/mysql/bin/mysqld --port=3306 --log-output=FILE</STARTUP_OPTIONS>
<STATUS>
mysql_errno()<STATUS_CODE><STATUS>
<STATUS>1051</STATUS>
<STATUS_CODE>
STATUS_CODESTATUS_CODEmysql_errno()
<STATUS_CODE>0</STATUS_CODE>
<USER>
<PRIV_USER>
<USER>root[root] @ localhost [127.0.0.1]</USER>
<VERSION>
<VERSION>1</VERSION>
audit_log_format=JSONJSONJSON
【{“时间戳”:“2018-01-15 13:50:01”、“身份证”:0、“阶级”:“审计”、“事件”:“启动”,…},{“时间戳”:“2018-01-15 15:02:32”、“身份证”:0,“阶级”:“连接”、“事件”:“连接”,…},…{“时间戳”:“2018-01-15 17:37:26”、“身份证”:0,“阶级”:“table_access”、“事件”:“插入”,…}…]
[
"\"
class
{ "timestamp": "2018-01-15 14:21:56",
"id": 0,
"class": "audit",
"event": "startup",
"connection_id": 0,
"startup_data": { "server_id": 1,
"os_version": "i686-Linux",
"mysql_version": "5.7.21-log",
"args": ["/usr/local/mysql/bin/mysqld",
"--loose-audit-log-format=JSON",
"--log-error=log.err",
"--pid-file=mysqld.pid",
"--port=3306" ] } }
connection_idlogin
{ "timestamp": "2018-01-15 14:28:20",
"id": 3,
"class": "audit",
"event": "shutdown",
"connection_id": 0,
"shutdown_data": { "server_id": 1 } }
connection_idlogin
{ "timestamp": "2018-01-15 14:23:18",
"id": 1,
"class": "connection",
"event": "connect",
"connection_id": 5,
"account": { "user": "root", "host": "localhost" },
"login": { "user": "root", "os": "", "ip": "::1", "proxy": "" },
"connection_data": { "connection_type": "ssl",
"status": 0,
"db": "test" } }
{ "timestamp": "2018-01-15 14:24:45",
"id": 3,
"class": "connection",
"event": "disconnect",
"connection_id": 5,
"account": { "user": "root", "host": "localhost" },
"login": { "user": "root", "os": "", "ip": "::1", "proxy": "" },
"connection_data": { "connection_type": "ssl" } }
{ "timestamp": "2018-01-15 14:23:35",
"id": 2,
"class": "general",
"event": "status",
"connection_id": 5,
"account": { "user": "root", "host": "localhost" },
"login": { "user": "root", "os": "", "ip": "::1", "proxy": "" },
"general_data": { "command": "Query",
"sql_command": "show_variables",
"query": "SHOW VARIABLES",
"status": 0 } }
{ "timestamp": "2018-01-15 14:23:41",
"id": 0,
"class": "table_access",
"event": "insert",
"connection_id": 5,
"account": { "user": "root", "host": "localhost" },
"login": { "user": "root", "os": "", "ip": "127.0.0.1", "proxy": "" },
"table_access_data": { "db": "test",
"table": "t1",
"query": "INSERT INTO t1 (i) VALUES(1),(2),(3)",
"sql_command": "insert" } }
JSON
account
CURRENT_USER()host
"account": { "user": "root", "host": "localhost" }
class
event
"class": "connection"
class
audit | startup |
|---|---|
connection | connectdisconnect |
general | status |
table_access_data | readinsert |
connection_data
connection_typedbconnection
"connection_data": { "connection_type": "ssl",
"status": 0,
"db": "test" }
connection_id
CONNECTION_ID()
"connection_id": 5
event
class
"event": "connect"
general_data
commandqueryclass
"general_data": { "command": "Query",
"sql_command": "show_variables",
"query": "SHOW VARIABLES",
"status": 0 }
id
"id": 2
timestamptimestamp
login
userip
"login": { "user": "root", "os": "", "ip": "::1", "proxy": "" }
shutdown_data
server_ideventshutdown
"shutdown_data": { "server_id": 1 }
startup_data
server_idmysql_versionclassaudit
"startup_data": { "server_id": 1,
"os_version": "i686-Linux",
"mysql_version": "5.7.21-log",
"args": ["/usr/local/mysql/bin/mysqld",
"--loose-audit-log-format=JSON",
"--log-error=log.err",
"--pid-file=mysqld.pid",
"--port=3306" ] }
table_access_data
dbqueryclass
"table_access_data": { "db": "test",
"table": "t1",
"query": "INSERT INTO t1 (i) VALUES(1),(2),(3)",
"sql_command": "insert" }
timestamp
YYYY-MM-DD hh:mm:ss
"timestamp": "2018-01-15 13:50:01"
timestamptimestamp
args
"args": ["/usr/local/mysql/bin/mysqld",
"--loose-audit-log-format=JSON",
"--log-error=log.err",
"--pid-file=mysqld.pid",
"--port=3306" ]
command
"command": "Query"
connection_type
tcp/ipsocketshared_memory
"connection_type": "tcp/tcp"
db
connection_data
"db": "test"
host
"host": "localhost"
ip
"ip": "::1"
mysql_version
VERSION()version
"mysql_version": "5.7.21-log"
os
external_user
"os": "jeffrey"
os_version
"os_version": "i686-Linux"
proxy
"proxy": "developer"
query
"query": "DELETE FROM t1"
server_id
server_id
"server_id": 1
sql_command
"sql_command": "insert"
statement/sql/xxxxxxselectDROP
TABLESELECT
选择替换(event_name,声明/ SQL / ',')是从performance_schema.events_statements_summary_global_by_event_namewhere event_name喜欢声明/ SQL / %是的名字;
status
mysql_errno()
"status": 1051
table
"table": "t1"
user
user
account
login
"user": "root"
audit_log_file
audit_log_file
.gz
.enc
audit_log_file
audit.log Not compressed or encrypted audit.log.gz Compressed audit.log.enc Encrypted audit.log.gz.enc Compressed and encrypted
audit.logYYYYMMDDThhmmss
audit_log_format
audit_log_formataudit_log_file
audit_log_compressionGZIP
audit_log_encryptionAES
audit_log_encryption_password_set()audit.20180115T140633.log.encYYYYMMDDhhmmss
audit_log_encryption_password_get()
audit_log_encryption_password_get()
audit_log_file
audit.timestamp.log Not compressed or encrypted audit.timestamp.log.gz Compressed audit.timestamp.log.enc Encrypted audit.timestamp.log.gz.enc Compressed and encrypted
gunzip -c audit.timestamp.log.gz > audit.timestamp.log
openssl enc -d -aes-256-cbc -pass pass:password-md sha256 -in audit.timestamp.log.enc -out audit.timestamp.log
.gz
openssl enc -d -aes-256-cbc -pass pass:password-md sha256 -in audit.timestamp.log.gz.enc -out audit.timestamp.log.gz gunzip -c audit.timestamp.log.gz > audit.timestamp.log
audit_log_strategyPERFORMANCEsync()
audit_log_buffer_size
audit_log_strategy
PERFORMANCE
audit_log_rotate_on_sizeaudit_log_flush
audit_log_rotate_on_size=0audit_log_flushaudit.log.1.xml
mv audit.log.2.xml audit.log.3.xml mv audit.log.1.xml audit.log.2.xml mv audit.log audit.log.1.xml
audit.log.1.xml
audit.log
SET GLOBAL audit_log_flush = ON;
audit_log_rotate_on_size
audit_log_rotate_on_sizeaudit_log_flushaudit_log_rotate_on_size
audit.logYYYYMMDDThhmmss
audit_log_fileaudit_log_file
basename[.timestamp].suffix[.gz][.enc]
audit_log_read()
MySQL的> SELECT audit_log_read(audit_log_read_bookmark());----------------------------------------------------------------------- | audit_log_read(audit_log_read_bookmark())| ----------------------------------------------------------------------- | [ {“时间戳”:“2018-01-15 22:41:24”、“身份证”:0、“阶级”:“连接”,…| -----------------------------------------------------------------------
audit_log_read()JSONJSON
[
{ "timestamp": "2018-01-15 22:08:08", "id": 10,
"class": "general", "event": "status",
...
},
{
"timestamp": "2018-01-15 22:08:08", "id": 11,
"class": "connection", "event": "disconnect",
...
},
{
"timestamp": "2018-01-15 13:39:33", "id": 0,
"class": "connection", "event": "connect",
...
},
{
"timestamp": "2018-01-15 13:39:33", "id": 1,
"class": "general", "event": "status",
...
},
{
"timestamp": "2018-01-15 13:39:33", "id": 2,
"class": "connection", "event": "disconnect",
...
},
null
]
audit_log_read()
JSON
timestamp
max_array_length
JSON
mysql> SELECT @mark := audit_log_read_bookmark() AS mark;
+-------------------------------------------------+
| mark |
+-------------------------------------------------+
| { "timestamp": "2018-01-15 16:10:28", "id": 2 } |
+-------------------------------------------------+
audit_log_read()utf8mb4
mysql>SET @mark = CONVERT(@mark USING utf8mb4);mysql>SET @mark := JSON_SET(@mark, '$.max_array_length', 1);mysql>SELECT @mark;+----------------------------------------------------------------------+ | @mark | +----------------------------------------------------------------------+ | {"id": 2, "timestamp": "2018-01-15 16:10:28", "max_array_length": 1} | +----------------------------------------------------------------------+
audit_log_read()
audit_log_read()audit_log_read_buffer_sizeaudit_log_read_buffer_sizeaudit_log_read_buffer_size
audit_log_read()
audit_log_read()
audit_log_read()
mysql
audit_log_filter_id
SELECT audit_log_filter_set_filter('log_all', '{ "filter": { "log": true } }');
SELECT audit_log_filter_set_user('%', 'log_all');
%
audit_log_filter_set_filter()
audit_log_filter_remove_filter()
audit_log_filter_set_user()
audit_log_filter_remove_user()
audit_log_filter_flush()
audit_log
MySQL >选择audit_log_filter_flush();---------------------------------------------------------------------------- | audit_log_filter_flush() | ---------------------------------------------------------------------------- |错误:audit_log插件没有安装安装插件的语法。| ----------------------------------------------------------------------------
mysql> SELECT audit_log_filter_flush(); +--------------------------------------------------+ | audit_log_filter_flush() | +--------------------------------------------------+ | ERROR: Could not reinitialize audit log filters. | +--------------------------------------------------+
audit_log
SUPER
MySQL的> SELECT audit_log_filter_flush()\G*************************** 1。行*************************** audit_log_filter_flush():错误:请求“user1”@ 'localhost忽视”。需要执行的操作super_acl
SUPER
格兰特超级*。* user;
SUPER
audit_log
[Warning] Plugin audit_log reported: 'Failed to open the audit log filter tables.' [Warning] Plugin audit_log reported: 'Audit Log plugin supports a filtering, which has not been installed yet. Audit Log plugin will run in the legacy mode, which will be disabled in the next release.'
SUPER
JSONJSON
%
log_conn_events%
SET @f = '{ "filter": { "class": { "name": "connection" } } }';SELECT audit_log_filter_set_filter('log_conn_events', @f);SELECT audit_log_filter_set_user('%', 'log_conn_events');SELECT audit_log_filter_set_filter('log_all', '{ "filter": { "log": true } }');
SELECT audit_log_filter_set_user('user1@localhost', 'log_all');
SELECT audit_log_filter_set_user('user2@localhost', 'log_all');
user1@localhost
SELECT audit_log_filter_remove_user('user1@localhost');
SELECT audit_log_filter_set_filter('log_nothing', '{ "filter": { "log": false } }');
SELECT audit_log_filter_set_user('user1@localhost', 'log_nothing');
user1@localhost
SELECT audit_log_filter_remove_filter('log_nothing');
mysqlINSERTUPDATEDELETE
SELECT audit_log_filter_flush();
audit_log_filter_id
MySQL的> SELECT @@audit_log_filter_id;----------------------- | @ @ audit_log_filter_id | ----------------------- | 2 | -----------------------
JSONJSON
actions
{“过滤器”: actions}
log
{“过滤”:{“日志”:真} }
logfalse
{
"filter": { }
}
logevent
log
logclassfalseevent
class
{
"filter": {
"class": { "name": "connection" }
}
}
namegeneral
connection
{
"filter": {
"log": false,
"class": { "log": true,
"name": "connection" }
}
}
classJSON
{“过滤”:{“类”:[ {“名字”:“连接”},{“名字”:“一般”},{“名字”:“table_access”} } } ]
{
"filter": {
"class": [
{ "name": [ "connection", "general", "table_access" ] }
]
}
}
eventevent
{“过滤”:{“类”:[ {“名字”:“连接”、“事件”:[ {“名字”:“连接”},{“名字”:“断开”}】},{“名字”:“一般”},{“名字”:“table_access”、“事件”:[ {“名字”:“插入”},{“名字”:“删除”},{“名字”:“更新”} } } } ] ]
eventevent
“Event”:[ {”:“read”,“log”,“log”:false },{”},{”}“插入”,“log”:true },{”}“del删除”,“log”:true },{“name”:“update”,“log”:true } ] ]
event
connection | connect | |
connection | change_user | |
connection | disconnect | |
general | status | |
table_access | read | SELECTINSERT
INTO ... SELECT |
table_access | delete | DELETETRUNCATE TABLE |
table_access | insert | INSERTREPLACE |
table_access | update | UPDATE |
connection | connect | ||
connection | change_user | ||
connection | disconnect | ||
general | status | ||
table_access | read | ||
table_access | delete | ||
table_access | insert | ||
table_access | update |
connectconnection
{
"filter": {
"log": false,
"class": [
{
"name": "connection",
"event": [
{ "name": "connect", "log": true },
{ "name": "disconnect", "log": true }
]
},
{ "name": "general", "log": true }
]
}
}
general
{“过滤”:{“日志”:真的,“阶级”:{“名字”:“一般”,“日志”:假} } }
change_usertable_access
{“过滤”:{“日志”:真的,“阶级”:[ {“名字”:“连接”、“事件”:[ {“名字”:“连接”、“日志”:假},{“名字”:“断开”,“日志”:假}】},{“名字”:“一般”,“日志”:假} } } ]
field
{
"filter": {
"class": {
"name": "general",
"event": {
"name": "status",
"log": {
"field": { "name": "general_command.str", "value": "Query" }
}
}
}
}
}
status | ||
connection_id | ||
user.str | ||
user.length | ||
priv_user.str | ||
priv_user.length | ||
external_user.str | ||
external_user.length | ||
proxy_user.str | ||
proxy_user.length | ||
host.str | ||
host.length | ||
ip.str | ||
ip.length | ||
database.str | ||
database.length | ||
connection_type |
|
"::xxx"
general_error_code | ||
general_thread_id | ||
general_user.str | ||
general_user.length | ||
general_command.str | ||
general_command.length | ||
general_query.str | ||
general_query.length | ||
general_host.str | ||
general_host.length | ||
general_sql_command.str | ||
general_sql_command.length | ||
general_external_user.str | ||
general_external_user.length | ||
general_ip.str | ||
general_ip.length |
general_command.strExecuteChange user
general_command.strExecutealter_dbadmin_commands
MySQL的> SELECT NAME FROM performance_schema.setup_instrumentsWHERE NAME LIKE 'statement/sql/%' ORDER BY NAME;--------------------------------------- |名字| --------------------------------------- |声明/ SQL / alter_db | |声明/ SQL / alter_db_upgrade | |声明/ SQL / alter_event | |声明/ SQL / alter_function | |声明/ SQL / alter_instance | |声明/ SQL / alter_procedure | |声明/ SQL / alter_server |…
connection_id | ||
sql_command_id | ||
query.str | ||
query.length | ||
table_database.str | ||
table_database.length | ||
table_name.str | ||
table_name.length |
read
SELECT
INSERT ... SELECT
REPLACE ... SELECT
UPDATE ... WHERE
HANDLER ... READ
delete
DELETE
TRUNCATE TABLE
insert
INSERT
INSERT ... SELECT
REPLACE
REPLACE ... SELECT
LOAD DATA INFILE
LOAD XML INFILE
update
UPDATE
UPDATE ... WHERE
eventabort
abort
"event": {
"name": qualifying event subclass names
"abort": condition
}
namecondition
conditionfalse
{“过滤”:{“类”:{“名字”:“table_access”、“事件”:{“名字”:[“插入”、“修改”、“删除”],“中止”:真} } } }
finances.bank_account
{“过滤”:{“类”:{“名字”:“table_access”、“事件”:{“名字”:[“插入”、“修改”、“删除”],“中止”:{“”:[ {“场”:{“名字”:“table_database。STR”、“价值”:“财政”} },{“场”:{“名字”:“table_name。STR”、“价值”:“bank_account”} } } } } } } ]
ERROR 1045 (28000): Statement was aborted by an audit log filter
abort
andnot
{
"filter": {
"class": {
"name": "general",
"event": {
"name": "status",
"log": {
"or": [
{
"and": [
{ "field": { "name": "general_command.str", "value": "Query" } },
{ "field": { "name": "general_command.length", "value": 5 } }
]
},
{
"and": [
{ "field": { "name": "general_command.str", "value": "Execute" } },
{ "field": { "name": "general_command.length", "value": 7 } }
]
}
]
}
}
}
}
}
log
{
"filter": {
"class": {
"name": "general",
"event": {
"name": "status",
"log": {
"variable": {
"name": "audit_log_connection_policy_value", "value": "::none"
}
}
}
}
}
}
audit_log_connection_policy_valueaudit_log_connection_policy
audit_log_xxx_policySHOW
VARIABLES
variable
audit_log_connection_policy_value
audit_log_connection_policyaudit_log_connection_policy
0 | NONE |
1 | ERRORS |
2 | ALL |
"::xxx"
audit_log_policy_value
audit_log_policyaudit_log_policy
0 | NONE |
1 | LOGINS |
2 | ALL |
3 | QUERIES |
"::xxx"
audit_log_statement_policy_value
audit_log_statement_policyaudit_log_statement_policy
0 | NONE |
1 | ERRORS |
2 | ALL |
"::xxx"
logname
{
"filter": {
"class": {
"name": "general",
"event": {
"name": "status",
"log": {
"function": {
"name": "find_in_include_list",
"args": [ { "string": [ { "field": "user.str" },
{ "string": "@"},
{ "field": "host.str" } ] } ]
}
}
}
}
}
}
name
generalaudit_log_include_accounts
function
audit_log_exclude_accounts_is_null()
audit_log_exclude_accounts
audit_log_include_accounts_is_null()
audit_log_include_accounts
debug_sleep(millisec)
debug_sleep()
millisec
find_in_exclude_list(account)
audit_log_exclude_accounts
account
find_in_include_list(account)
audit_log_include_accounts
account
string_find(text, substr)
substr
text
substr
filter
{
"filter": {
"id": "main",
"class": {
"name": "table_access",
"event": {
"name": [ "update", "delete" ],
"log": false,
"filter": {
"class": {
"name": "general",
"event" : { "name": "status",
"filter": { "ref": "main" } }
},
"activate": {
"or": [
{ "field": { "name": "table_name.str", "value": "temp_1" } },
{ "field": { "name": "table_name.str", "value": "temp_2" } }
]
}
}
}
}
}
}
activateactivate
ref
mainupdate
updatetable_accesstemp_2
generalmain
temp_1
UPDATE temp_1, temp_3 SET temp_1.a=21, temp_3.a=23;
table_accessstatus
idaudit_log_filter_id
audit_log
audit_log_include_accounts
audit_log_exclude_accounts
NULLuser_namehost_name
audit_log_include_accountsaudit_log_exclude_accounts
user1audit_log_include_accounts
SET GLOBAL audit_log_include_accounts = 'user1@localhost,user2@localhost';
audit_log_include_accountsaudit_log_exclude_accounts
audit_log_include_accountsaudit_log_exclude_accounts
audit_log_exclude_accountsaudit_log_include_accountsaudit_log_include_accounts
-- This sets audit_log_exclude_accounts to NULL SET GLOBAL audit_log_include_accounts =value; -- This fails because audit_log_include_accounts is not NULL SET GLOBAL audit_log_exclude_accounts =value; -- To set audit_log_exclude_accounts, first set -- audit_log_include_accounts to NULL SET GLOBAL audit_log_include_accounts = NULL; SET GLOBAL audit_log_exclude_accounts =value;
SHOW VARIABLESSELECT
MySQL的> SHOW VARIABLES LIKE 'audit_log_include_accounts';---------------------------- ------- | variable_name |价值| ---------------------------- ------- | audit_log_include_accounts | | ---------------------------- ------- MySQL > SELECT @@audit_log_include_accounts;------------------------------ | @ @ audit_log_include_accounts | ------------------------------ |空| ------------------------------
root
SET GLOBAL audit_log_include_accounts = 'root@localhost';SET GLOBAL audit_log_include_accounts = '''root''@''localhost''';SET GLOBAL audit_log_include_accounts = '\'root\'@\'localhost\'';SET GLOBAL audit_log_include_accounts = "'root'@'localhost'";
ANSI_QUOTES
audit_log_connection_policy
audit_log_statement_policy
ALLNONE
SET GLOBAL audit_log_statement_policy = ALL;SET GLOBAL audit_log_connection_policy = ERRORS;
audit_log_policyaudit_log_connection_policyaudit_log_statement_policyLOGINSNONEaudit_log_policy
audit_log_policyaudit_log_connection_policyaudit_log_statement_policy
audit_log_policyaudit_log_connection_policyaudit_log_statement_policy
LOGINS | ALL | NONE |
QUERIES | NONE | ALL |
NONE | NONE | NONE |
audit_log
mysql
audit_log
audit_log_filter
NAME
FILTER
JSON
audit_log_user
USER
user1@localhostuser1
HOST
user1@localhostlocalhost
FILTERNAME
audit_log_filter
OKmessage
audit_log_encryption_password_get()
STRING audit_log_encryption_password_get()
NULL
mysql> SELECT audit_log_encryption_password_get();
+-------------------------------------+
| audit_log_encryption_password_get() |
+-------------------------------------+
| secret |
+-------------------------------------+
audit_log_encryption_password_set()
INTEGER audit_log_encryption_password_set()
mysql>SELECT audit_log_encryption_password_set(+---------------------------------------------+ | audit_log_encryption_password_set(password);password) | +---------------------------------------------+ | 1 | +---------------------------------------------+
audit_log_filter_flush()
INSERTUPDATEDELETE
audit_log_filter_flush()
audit_log_filter_flush()
STRING audit_log_filter_flush()
OKmessage
mysql> SELECT audit_log_filter_flush();
+--------------------------+
| audit_log_filter_flush() |
+--------------------------+
| OK |
+--------------------------+
audit_log_filter_remove_filter()
audit_log_user
STRING audit_log_filter_remove_filter(STRING filter_name)
filter_name
OKmessage
mysql> SELECT audit_log_filter_remove_filter('SomeFilter');
+----------------------------------------------+
| audit_log_filter_remove_filter('SomeFilter') |
+----------------------------------------------+
| OK |
+----------------------------------------------+
audit_log_filter_remove_user()
%
STRING audit_log_filter_remove_user(STRING user_name)
user_nameuser_namehost_name
OKmessage
mysql> SELECT audit_log_filter_remove_user('user1@localhost');
+-------------------------------------------------+
| audit_log_filter_remove_user('user1@localhost') |
+-------------------------------------------------+
| OK |
+-------------------------------------------------+
audit_log_filter_set_filter()
STRING audit_log_filter_set_filter(STRING filter_name, STRING definition)
filter_name
definitionJSON
OKmessage
mysql>SET @f = '{ "filter": { "log": false } }';mysql>SELECT audit_log_filter_set_filter('SomeFilter', @f);+-----------------------------------------------+ | audit_log_filter_set_filter('SomeFilter', @f) | +-----------------------------------------------+ | OK | +-----------------------------------------------+
audit_log_filter_set_user()
%
STRING audit_log_filter_set_user(STRING user_name, STRING filter_name)
user_nameuser_namehost_name
filter_name
OKmessage
mysql> SELECT audit_log_filter_set_user('user1@localhost', 'SomeFilter');
+------------------------------------------------------------+
| audit_log_filter_set_user('user1@localhost', 'SomeFilter') |
+------------------------------------------------------------+
| OK |
+------------------------------------------------------------+
audit_log_read()
JSON
JSONJSON
audit_log_read()JSONaudit_log_read()
JSONaudit_log_read()
audit_log_read_bookmark()
STRING audit_log_read([STRING arg])
argJSON
timestamp
max_array_length
JSON
mysql> SELECT audit_log_read(audit_log_read_bookmark());
+-----------------------------------------------------------------------+
| audit_log_read(audit_log_read_bookmark()) |
+-----------------------------------------------------------------------+
| [ {"timestamp":"2018-01-15 22:41:24","id":0,"class":"connection", ... |
+-----------------------------------------------------------------------+
audit_log_read_bookmark()
JSON
JSONid
STRING audit_log_read_bookmark()
JSON
mysql> SELECT audit_log_read_bookmark();
+-------------------------------------------------+
| audit_log_read_bookmark() |
+-------------------------------------------------+
| { "timestamp": "2018-01-15 21:03:44", "id": 0 } |
+-------------------------------------------------+
audit_log
--audit-log[=value] | |
ON | |
|
audit_logINSTALL
PLUGIN--plugin-load--plugin-load-add
--audit-log=FORCE_PLUS_PERMANENT
mysql> SHOW VARIABLES LIKE 'audit_log%';
+-----------------------------+--------------+
| Variable_name | Value |
+-----------------------------+--------------+
| audit_log_buffer_size | 1048576 |
| audit_log_connection_policy | ALL |
| audit_log_current_session | OFF |
| audit_log_exclude_accounts | |
| audit_log_file | audit.log |
| audit_log_filter_id | 0 |
| audit_log_flush | OFF |
| audit_log_format | NEW |
| audit_log_include_accounts | |
| audit_log_policy | ALL |
| audit_log_rotate_on_size | 0 |
| audit_log_statement_policy | ALL |
| audit_log_strategy | ASYNCHRONOUS |
+-----------------------------+--------------+
--audit-log-buffer-size=value | |
audit_log_buffer_size | |
1048576 | |
4096 | |
18446744073709547520 | |
4294967295 |
--audit-log-compression=value | |
audit_log_compression | |
NONE | |
|
NONE
--audit-log-connection-policy=value | |
audit_log_connection_policy | |
ALL | |
|
ALL | |
ERRORS | |
NONE |
audit_log_connection_policyaudit_log_policy
audit_log_current_session | |
depends on filtering policy |
audit_log_include_accountsaudit_log_exclude_accounts
--audit-log-encryption=value | |
audit_log_encryption | |
NONE | |
|
NONE
--audit-log-exclude-accounts=value | |
audit_log_exclude_accounts | |
NULL |
NULL
audit_log_exclude_accounts
--audit-log-file=file_name | |
audit_log_file | |
audit.log |
audit.logaudit.jsson
audit_log_file
audit_log_file
audit_log_file
audit_log_filter_id | |
audit_log_flush | |
OFF |
ONaudit_log_rotate_on_size
--audit-log-format=value | |
audit_log_format | |
NEW | |
|
OLDJSON
--audit-log-include-accounts=value | |
audit_log_include_accounts | |
NULL |
NULL
audit_log_include_accounts
--audit-log-policy=value | |
audit_log_policy | |
ALL | |
|
ALL | |
LOGINS | |
QUERIES | |
NONE |
audit_log_policyaudit_log_connection_policyaudit_log_statement_policyaudit_log_policy
--audit-log-read-buffer-size=# | |
audit_log_read_buffer_size | |
32768 | |
1048576 | |
32768 | |
1024 | |
4194304 |
audit_log_read()
audit_log_read_buffer_sizeaudit_log_read_buffer_size
--audit-log-rotate-on-size=N | |
audit_log_rotate_on_size | |
0 |
audit_log_rotate_on_sizeaudit_log_flush
audit_log_rotate_on_sizeaudit_log_rotate_on_size
--audit-log-statement-policy=value | |
audit_log_statement_policy | |
ALL | |
|
ALL | |
ERRORS | |
NONE |
audit_log_statement_policyaudit_log_policy
--audit-log-strategy=value | |
audit_log_strategy | |
ASYNCHRONOUS | |
|
ASYNCHRONOUS
PERFORMANCE
SEMISYNCHRONOUS
SYNCHRONOUS
audit_log_buffer_size
Audit_log_current_sizeAudit_log_total_size
LOAD DATA
INFILE
MYSQL_FIREWALL
MYSQL_FIREWALL_USERSINFORMATION_SCHEMA
firewall_usersmysql
sp_set_firewall_mode()
FIREWALL_ADMINFIREWALL_USER
share
share
win_install_firewall.sql
linux_install_firewall.sql
mysql
内核> mysql -u root -p mysql < linux_install_firewall.sql输入密码: (enter root password here)
mysql> SHOW GLOBAL VARIABLES LIKE 'mysql_firewall_mode';
+---------------------+-------+
| Variable_name | Value |
+---------------------+-------+
| mysql_firewall_mode | ON |
+---------------------+-------+
mysqlDROP PROCEDURE
表MySQL。firewall_whitelist;表MySQL。firewall_users;卸载插件mysql_firewall;卸载插件mysql_firewall_whitelist;卸载插件mysql_firewall_users;降功能set_firewall_mode;降功能normalize_statement;降功能read_firewall_whitelist;降功能read_firewall_users;降功能mysql_firewall_flush_status;下降过程sp_set_firewall_mode;下降过程mysql.sp_reload_firewall_rules MySQL;
mysql_firewall_mode
[mysqld]mysql_firewall_mode=ON
mysql>SET GLOBAL mysql_firewall_mode = OFF;mysql>SET GLOBAL mysql_firewall_mode = ON;
max_digest_length
mysql_firewall_trace
OFF
'fwuser'@'localhost'
CREATE
USERGRANT
@
sakila
sakila
MySQL的> CREATE USER 'fwuser'@'localhost' IDENTIFIED BY 'fWp@3sw0rd';MySQL的> GRANT ALL ON sakila.* TO 'fwuser'@'localhost';
sp_set_firewall_mode()
mysql> CALL mysql.sp_set_firewall_mode('fwuser@localhost', 'RECORDING');
mysql>SELECT first_name, last_name FROM customer WHERE customer_id = 1;mysql>UPDATE rental SET return_date = NOW() WHERE rental_id = 1;mysql>SELECT get_customer_balance(1, NOW());
INFORMATION_SCHEMA
MySQL的> SELECT MODE FROM INFORMATION_SCHEMA.MYSQL_FIREWALL_USERSWHERE USERHOST = 'fwuser@localhost';----------- |模式| ----------- |记录| ----------- MySQL > SELECT RULE FROM INFORMATION_SCHEMA.MYSQL_FIREWALL_WHITELISTWHERE USERHOST = 'fwuser@localhost';+----------------------------------------------------------------------------+| RULE |+----------------------------------------------------------------------------+| SELECT `first_name` , `last_name` FROM `customer` WHERE `customer_id` = ? || SELECT `get_customer_balance` ( ? , NOW ( ) ) || UPDATE `rental` SET `return_date` = NOW ( ) WHERE `rental_id` = ? || SELECT @@`version_comment` LIMIT ? |+----------------------------------------------------------------------------+
@@version_comment
mysql> CALL mysql.sp_set_firewall_mode('fwuser@localhost', 'PROTECTING');
RECORDING
mysql> SELECT first_name, last_name FROM customer WHERE customer_id = '48';
+------------+-----------+
| first_name | last_name |
+------------+-----------+
| ANN | EVANS |
+------------+-----------+
mysql>SELECT first_name, last_name FROM customer WHERE customer_id = 1 OR TRUE;ERROR 1045 (28000): Statement was blocked by Firewall mysql>SHOW TABLES LIKE 'customer%';ERROR 1045 (28000): Statement was blocked by Firewall mysql>TRUNCATE TABLE mysql.slow_log;ERROR 1045 (28000): Statement was blocked by Firewall
mysql_firewall_trace
[注]插件mysql_firewall报道:为fwuser @本地'access否认。原因:在白名单中没有匹配。声明:截断表` MySQL `。` slow_log `”
mysql> CALL mysql.sp_set_firewall_mode('fwuser@localhost', 'DETECTING');
mysql> SHOW TABLES LIKE 'customer%';
+------------------------------+
| Tables_in_sakila (customer%) |
+------------------------------+
| customer |
| customer_list |
+------------------------------+
[Note] Plugin MYSQL_FIREWALL reported: 'SUSPICIOUS STATEMENT from 'fwuser@localhost'. Reason: No match in whitelist. Statement: SHOW TABLES LIKE ? '
mysql> SHOW GLOBAL STATUS LIKE 'Firewall%';
+----------------------------+-------+
| Variable_name | Value |
+----------------------------+-------+
| Firewall_access_denied | 3 |
| Firewall_access_granted | 4 |
| Firewall_access_suspicious | 1 |
| Firewall_cached_entries | 4 |
+----------------------------+-------+
Firewall_access_grantedSHOW TABLES
INFORMATION_SCHEMA
INFORMATION_SCHEMA
INFORMATION_SCHEMA.MYSQL_FIREWALL_USERS
USERHOST
user_name@host_name
MODE
OFFPROTECTINGRESET
INFORMATION_SCHEMA.MYSQL_FIREWALL_WHITELIST
USERHOST
RULE
ID
CALL mysql.sp_set_firewall_mode(user,mode);
sp_reload_firewall_rules(user)
mysql.firewall_whitelist
useruser_namehost_name
CALL mysql.sp_reload_firewall_rules('fwuser@localhost');
RESETOFFsp_set_firewall_mode()sp_reload_firewall_rules()
sp_set_firewall_mode(user,
mode)
mysql_firewall_mode
useruser_namehost_name
mode
OFF
DETECTING
PROTECTING
RECORDING
RESET
RECORDINGOFFmysql.firewall_whitelist
PROTECTING
MySQL的> CALL mysql.sp_set_firewall_mode('a@b','PROTECTING');---------------------------------------------------------------------- | set_firewall_mode(arg_userhost,arg_mode)| ---------------------------------------------------------------------- |错误:保护要求一个“B模式但白名单是空的。| ----------------------------------------------------------------------一行集(0.02秒)查询好,为受影响的行(0.02秒)
mysql_firewall_flush_status()
Firewall_access_denied Firewall_access_granted Firewall_access_suspicious
SELECT mysql_firewall_flush_status();
normalize_statement(stmt)
SELECT normalize_statement('SELECT * FROM t1 WHERE c1 > 2');
read_firewall_users(user,
mode)
SELECT
SELECT read_firewall_users('fwuser@localhost', 'RECORDING')
FROM mysql.firewall_users;
read_firewall_whitelist(user,
rule)
SELECT
SELECT read_firewall_whitelist('fwuser@localhost', 'RECORDING')
FROM mysql.firewall_whitelist;
set_firewall_mode(user,
mode)
SELECT set_firewall_mode('fwuser@localhost', 'RECORDING');
--mysql-firewall-mode={OFF|ON} | |
mysql_firewall_mode | |
ON |
--mysql-firewall-trace={OFF|ON} | |
mysql_firewall_trace | |
OFF |
mysql_firewall_trace
MYSQL_FIREWALL
DETECTING
ssl_fips_mode
--ssl-fips-mode
ssl_fips_mode--ssl-fips-mode
OFF
ON
STRICT
ssl_fips_modeON
STRICTON
ssl_fips_mode--ssl-fips-mode
RC4-MD5CREATE USERALTER USERrequire_secure_transport