root
mysql
GRANT
REVOKE
mysql -u root
root
SHOW GRANTS
REVOKE
SHA2()
nmap
server_host
内核> telnet
server_host
3306
shell> tcpdump -l -i eth0 -w - src or dst port 3306 | strings
validate_password
.mylogin.cnf
-p
your_pass
--password=
your_pass
内核> mysql -u francis -pfrank
db_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_history
CREATE USER
ALTER USER
~/.bash_history
mysql.user
validate_password
plugin_dir
CREATE USER
GRANT
SET PASSWORD
CREATE USER ... IDENTIFIED BY ... ALTER USER ... IDENTIFIED BY ... SET PASSWORD ... SLAVE START ... PASSWORD = ... CREATE SERVER ... OPTIONS(... PASSWORD ...) ALTER SERVER ... OPTIONS(... PASSWORD ...)
INSERT
UPDATE
--log-raw
--log-raw
--log-raw
mysql
mysql
START
SLAVE
mysql -u
other_user
db_name
other_user
root
FILE
~root/.bashrc
root
--user=root
mysql
user
my.cnf
[mysqld]user=mysql
root
user
FILE
FILE
SELECT ... INTO
OUTFILE
FILE
LOAD
DATA
SELECT
secure_file_priv
PROCESS
SUPER
SHOW
PROCESSLIST
CONNECTION_ADMIN
SUPER
SUPER
--skip-symbolic-links
root
max_user_connections
CREATE
USER
ALTER USER
SELECT
... INTO DUMPFILE
plugin_dir
--secure-file-priv
SELECT
mysql
tar.gz
root
user_name
user_name
shell> chown -R user_name
/path/to/mysql/datadir
user_name
chown -R
user_name
root
--user=
user_name
user_name
user
/etc/my.cnf
[mysqld]
user=user_name
root
--user=root
LOAD DATA
LOCAL
LOAD
DATA
LOAD
DATA
LOAD DATA
LOCAL
LOAD DATA
LOCAL
LOAD DATA
--ssl-mode=VERIFY_IDENTITY
LOCAL
local_infile
local_infile
local_infile
LOAD DATA
LOCAL
local_infile
local_infile
ENABLED_LOCAL_INFILE
LOCAL
ENABLED_LOCAL_INFILE
ENABLED_LOCAL_INFILE
ENABLED_LOCAL_INFILE
mysql_options()
--local-infile=0
--local-infile[=1]
--local=0
--local[=1]
LOAD
DATA LOCAL
local-infile
loose-
[client]loose-local-infile=0
[client] loose-local-infile=1
LOCAL
LOCAL
LOAD DATA
LOCAL
错误1148:使用的命令是不允许使用这个版本的MySQL
; DROP DATABASE
mysql;
SELECT * FROM table WHERE ID=234
234 OR 1=1
SELECT * FROM table WHERE ID=234 OR 1=1
SELECT * FROM table WHERE ID='234'
'
%22
%23
%27
mysql_real_escape_string_quote()
escape
mysqli
ext/mysql
ext/mysql
mysql_real_escape_string_quote()
mysql_escape_string()
mysql_real_escape_string_quote()
quote()
quote()
PreparedStatement
SELECT
INSERT
UPDATE
DELETE
LOAD DATA
INFILE
CREATE USER
GRANT
REVOKE
mysql
joe
joe
joe
joe
SHOW GRANTS
显示“乔”'office补助。例如.com”;显示“乔”“返回”补助。例如.com”;
SELECT
DROP
user
tables_priv
procs_priv
mysql
GRANT
REVOKE
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 |
GRANT
REVOKE
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
FILE
SELECT
GRANT OPTION
GRANT OPTION
ALTER
SHUTDOWN
PROCESS
SUPER
mysql
authentication_string
ALL
ALL
PRIVILEGES
GRANT
OPTION
ALL
ALTER
ALTER TABLE
ALTER TABLE
CREATE
INSERT
ALTER
DROP
CREATE
INSERT
ALTER ROUTINE
CREATE
CREATE ROLE
CREATE
ROLE
CREATE
USER
CREATE ROLE
CREATE ROUTINE
CREATE TABLESPACE
CREATE TEMPORARY TABLES
CREATE TEMPORARY TABLE
DROP TABLE
INSERT
UPDATE
SELECT
CREATE USER
ALTER
USER
CREATE ROLE
CREATE USER
DROP ROLE
DROP USER
RENAME USER
REVOKE ALL
PRIVILEGES
CREATE VIEW
CREATE
VIEW
DELETE
DROP
DROP
DROP
TRUNCATE TABLE
DROP
DROP ROLE
DROP ROLE
CREATE USER
DROP
ROLE
EVENT
EXECUTE
FILE
LOAD DATA
INFILE
SELECT ... INTO
OUTFILE
LOAD_FILE()
FILE
FILE
FILE
INDEX
DIRECTORY
CREATE TABLE
secure_file_priv
GRANT OPTION
INDEX
INDEX
CREATE
CREATE TABLE
INSERT
INSERT
ANALYZE TABLE
OPTIMIZE TABLE
REPAIR TABLE
LOCK TABLES
LOCK
TABLES
SELECT
PROCESS
SHOW
PROCESSLIST
PROCESS
SHOW ENGINE
PROXY
REFERENCES
RELOAD
FLUSH
FLUSH
flush-logs
flush-status
flush-threads
reload
reload
reload
flush-
xxx
flush-logs
REPLICATION CLIENT
SHOW
MASTER STATUS
SHOW SLAVE
STATUS
SHOW BINARY
LOGS
REPLICATION SLAVE
SELECT
SELECT
SELECT
SELECT
SELECT
选择1 1;选择pi() *2;
SELECT
SELECT
col_name
=expr
UPDATE
DELETE
UPDATE
SHOW DATABASES
--skip-show-database
SHOW VIEW
SHOW CREATE
VIEW
EXPLAIN
SHUTDOWN
SHUTDOWN
RESTART
mysql_shutdown()
SUPER
SUPER
SUPER
binlog_format
sql_log_bin
sql_log_off
SYSTEM_VARIABLES_ADMIN
SYSTEM_VARIABLES_ADMIN
REPLICATION_SLAVE_ADMIN
GROUP_REPLICATION_ADMIN
CHANGE MASTER
TO
CHANGE REPLICATION
FILTER
REPLICATION_SLAVE_ADMIN
PURGE BINARY LOGS
BINLOG
BINLOG_ADMIN
DEFINER
SET_USER_ID
CREATE
SERVER
ALTER
SERVER
DROP
SERVER
InnoDB
ENCRYPTION_KEY_ADMIN
VERSION_TOKEN_ADMIN
<graphml>
ROLES_GRAPHML()
ROLE_ADMIN
SUPER
KILL
CONNECTION_ADMIN
SUPER
max_connections
CONNECTION_ADMIN
read_only
GRANT
REVOKE
CONNECTION_ADMIN
init_connect
SUPER
CONNECTION_ADMIN
offline_mode
SUPER
SUPER
CONNECTION_ADMIN
SUPER
TRIGGER
INSERT
UPDATE
DELETE
TRIGGER
UPDATE
USAGE
GRANT
SHOW GRANTS
USAGE
AUDIT_ADMIN
BACKUP_ADMIN
LOCK INSTANCE FOR
BACKUP
log_status
BACKUP_ADMIN
RELOAD
BINLOG_ADMIN
PURGE
BINARY LOGS
BINLOG
CONNECTION_ADMIN
CONNECTION_ADMIN
init_connect
init_connect
CONNECTION_ADMIN
offline_mode
offline_mode
CONNECTION_ADMIN
CONNECTION_ADMIN
read_only
read_only
GRANT
REVOKE
ENCRYPTION_KEY_ADMIN
FIREWALL_ADMIN
FIREWALL_USER
GROUP_REPLICATION_ADMIN
PERSIST_RO_VARIABLES_ADMIN
SET
PERSIST_ONLY
SET
PERSIST
REPLICATION_SLAVE_ADMIN
CHANGE MASTER TO
CHANGE REPLICATION FILTER
RESOURCE_GROUP_ADMIN
RESOURCE_GROUP_USER
SET
RESOURCE GROUP
ROLE_ADMIN
GRANT
<graphml>
ROLES_GRAPHML()
SET_USER_ID
SYSTEM_VARIABLES_ADMIN
SYSTEM_VARIABLES_ADMIN
binlog_format
sql_log_bin
sql_log_off
VERSION_TOKEN_ADMIN
XA_RECOVER_ADMIN
XA
RECOVER
XA
RECOVER
XA
RECOVER
XA_RECOVER_ADMIN
SELECT
INSERT
INSTALL COMPONENT 'my_component'; UNINSTALL COMPONENT 'my_component'; INSTALL COMPONENT 'my_component';
INSTALL COMPONENT
UNINSTALL COMPONENT
INSTALL
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 GRANTS
USER_PRIVILEGES
GRANT
REVOKE
GRANT
REVOKE
GRANT ALL
REVOKE ALL
FLUSH PRIVILEGES
SUPER
SUPER
SUPER
SUPER
SUPER
SUPER
SUPER
SUPER
SUPER
SELECT GRANTEE FROM INFORMATION_SCHEMA.USER_PRIVILEGESWHERE PRIVILEGE_TYPE = 'SUPER';
SUPER
SUPER
'u1'@'localhost'
SUPER
格兰特binlog_admin,system_variables_admin *。*“U1 '@'本地主机';撤销超*。*从U1 '@'本地主机';
INFORMATION_SCHEMA
mysql
CREATE USER
GRANT
REVOKE
INSERT
UPDATE
DELETE
mysql
user
global_grants
db
tables_priv
columns_priv
procs_priv
proxies_priv
default_roles
role_edges
password_history
InnoDB
CREATE
USER
GRANT
user
User
'bob'
bob
Host
Db
'bob'
bob
reports
columns_priv
user
SHOW
DATABASES
SCHEMATA
global_grants
db
tables_priv
db
procs_priv
proxies_priv
PROXY
default_roles
password_history
user
mysql
user
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 |
user
authentication_string
plugin
plugin
FLUSH
PRIVILEGES
plugin
[警告]用户入口” user_name
“@” host_name
“有一个空的pluginvalue。用户将被忽略,没有人可以用这useranymore登录。
password_expired
'N'
ALTER USER
ALTER USER
password_last_changed
NULL
sha256_password
NULL
password_last_changed
CREATE USER
ALTER USER
SET PASSWORD
GRANT
password_lifetime
N
N
default_password_lifetime
account_locked
Password_reuse_history
NULL
Password_reuse_time
NULL
Password_require_current
'Y' | PASSWORD REQUIRE CURRENT |
'N' | PASSWORD REQUIRE CURRENT OPTIONAL |
NULL | PASSWORD REQUIRE CURRENT DEFAULT |
user
tables_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 |
Timestamp
CURRENT_USER
procs_priv
Routine_type
ENUM
'PROCEDURE'
Timestamp
proxies_priv
PROXY
With_grant
Proxied_user
proxies_priv
PROXY
root
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 |
User
authentication_string
Table_name
Proxied_host
Routine_name
user
ENUM('N','Y') DEFAULT 'N'
tables_priv
procs_priv
SET
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' |
user
RELOAD
SHUTDOWN
FILE
FLUSH PRIVILEGES
SHOW GRANTS
pc84.example.com
显示“鲍勃”'pc84补助。例如.com”;
SHOW CREATE USER
显示创建用户“鲍勃”'pc84。例如.com”;
CREATE
USER
GRANT
SET PASSWORD
'
user_name
'@'host_name
'
'
user_name
'@'%''me'@'%'
user_name
host_name
%
`
"
'me'@'localhost'
'me@localhost'@'%'
CURRENT_USER
CURRENT_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”;
david
client_ip
client_ip
& netmask
=host_ip
CREATE USER
client_ip
& 255.255.255.0 = 198.51.100.0
198.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.com
host1
198.51.100.2
198.051.100.2
198.051.100.%
'%'
'%'
'%'
CURRENT_USER()
mysql.user
SET ROLE 'myrole'@'%';
'myrole'@'%'
'%'
user
User
user
Host
user
'N'
User
ALTER USER
User
user
authentication_string
authentication_string
mysql
User
user
User | Host | |
---|---|---|
'fred' | 'h1.example.net' | fred
|
'' | 'h1.example.net' | h1.example.net |
'fred' | '%' | fred |
'' | '%' | |
'fred' | '%.example.net' | fred
|
'fred' | 'x.example.%' | fred
x.example.com
|
'fred' | '198.51.100.177' | fred
|
'fred' | '198.51.100.%' | fred
|
'fred' | '198.51.100.0/255.255.255.0' |
user
fred
user
Host
198.51.100.0/255.255.255.0
''
'%'
User
Host
user
----------- ---------- - |主机|用户|…----------- ---------- - | % |根|…| % |杰夫瑞|…| localhost |根|…| localhost | |…----------- ----------—
+-----------+----------+- | Host | User | ... +-----------+----------+- | localhost | root | ... | localhost | | ... | % | jeffrey | ... | % | root | ... +-----------+----------+-
localhost
Host
'localhost'
'%'
'localhost'
user
---------------- ---------- - |主机|用户|…---------------- ---------- - | % |杰夫瑞|…| h1.example.net | |…---------------- ----------—
+----------------+----------+- | Host | User | ... +----------------+----------+- | h1.example.net | | ... | % | jeffrey | ... +----------------+----------+-
jeffrey
jeffrey
h1.example.net
'jeffrey'
jeffrey
CURRENT_USER()
user_name
@host_name
Host
jeffrey
MySQL的> SELECT CURRENT_USER();
---------------- | current_user() | ---------------- | @本地| ----------------
user
jeffrey
user
user
tables_priv
procs_priv
user
DELETE
user
db
db
db
Db
user
tables_priv
procs_priv
%
Host
LIKE
'%'
Db
Column_name
tables_priv
procs_priv
Db
db
SHUTDOWN
RELOAD
user
SHUTDOWN
Shutdown_priv
INSERT
UPDATE
user
db
Db
Host
Db
User
db
tables_priv
procs_priv
columns_priv
global privileges OR (database privileges AND host privileges) OR table privileges OR column privileges OR routine privileges
user
INSERT INTO ...
SELECT
INSERT
SELECT
db
GRANT
REVOKE
SET
PASSWORD
RENAME USER
INSERT
UPDATE
DELETE
FLUSH PRIVILEGES
USE
db_name
--skip-grant-tables
shell>mysql
ERROR 2003: Can't connect to MySQL server on 'host_name
' (111) shell>mysql
ERROR 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
mysql
var
mysql
root
内核> mysql -u root
错误1045(28000):拒绝访问用户的根'@'本地主机'(使用密码:无)
root
--password
-p
内核> mysql -u root -p
输入密码:
root
root
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 -p
xxxx
ver用户访问被拒绝的根'@'本地主机'(使用密码:是的)
--no-defaults
root
localhost
--host=127.0.0.1
--host
Access denied
using password: NO
Access denied
user_name
mysql -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)
root
User
Access denied for user ''@'unknown'
/etc/hosts
localhost
.
mysql -u root
your_hostname
your_hostname
Host
'pluto'
'pluto.example.com'
Host
Host
Host
mysql -u
user_name
user_name
some_db
some_db
mysql -u
user_name
host_name
user_name
Access
denied
Host
'_'
='%'
='
some_user
'Host
=User
=Host
'%'
Host
=User
=some_user
='localhost'
=''
FLUSH
PRIVILEGES
Access denied
SELECT ... INTO
OUTFILE
LOAD DATA
INFILE
FILE
INSERT
UPDATE
DELETE
FLUSH PRIVILEGES
root
UPDATE
mysql -u
user_name
db_name
user_name
your_pass
db_name
-p
--password=
your_pass
--password
--skip-grant-tables
SHOW GRANTS
--debug=d,general,query
--skip-grant-tables
user
user
-u
mysql
mysql
mysql_native_password
user
user
mysql_options()
--default-character-set
mysql_options()
mysql_options()
ucs2
utf32
root
CREATE USER
DROP USER
GRANT
REVOKE
shell> mysql --user=finley --password db_name
shell> mysql -u finley -p db_name
--password
shell>mysql --user=finley --password=
shell>password
db_name
mysql -u finley -p
password
db_name
-p
-p
CREATE USER
GRANT
INSERT
UPDATE
DELETE
phpMyAdmin
root
CREATE USER
root
内核> mysql --user=root mysql
root
-p
root
CREATE 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'
RELOAD
PROCESS
xxx
GRANT
'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没有到期默认帐户解锁密码
custom
password
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 ROLE
DROP ROLE
SHOW GRANTS
SET DEFAULT ROLE
SET ROLE
CURRENT_ROLE()
mandatory_roles
activate_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”;
GRANT
GRANT
格兰特app_developer”到“Dev1 '@'本地主机';格兰特app_read '到' read_user1 '@'本地主机',' read_user2 '@'本地主机';格兰特app_read ',' app_write '到' rw_user1 '@'本地主机';
GRANT
GRANT
ON
GRANT
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
PERSIST
GLOBAL
mandatory_roles
ROLE_ADMIN
SYSTEM_VARIABLES_ADMIN
SUPER
activate_all_roles_on_login
SET
ROLE
mandatory_roles
REVOKE
DROP ROLE
DROP USER
mandatory_roles
FLUSH
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_roles
rw_user1
CURRENT_ROLE()
mysql> SELECT CURRENT_ROLE();
+----------------+
| CURRENT_ROLE() |
+----------------+
| NONE |
+----------------+
SET DEFAULT ROLE
设置默认的角色dev1 all to“localhost”“@”,“@”读_ user1 localhost”、“读“@”_ user2 RW _ user1 localhost”、“localhost”“@”;
rw_user1
CURRENT_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
DEFINER
activate_all_roles_on_login
SET ROLE
REVOKErole
FROMuser
;
mandatory_roles
REVOKE
REVOKE
REVOKE INSERT, UPDATE, DELETE ON app_db.* FROM 'app_write';
SHOW GRANTS
MySQL的> SHOW GRANTS FOR 'app_write';
--------------------------------------- |补助app_write @ % | --------------------------------------- |授予使用*。* ` app_write ` @ ` % ` | ---------------------------------------
rw_user1
INSERT
UPDATE
DELETE
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';
u2
u1
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'
sys
root
'mysql.session'@'localhost'
'mysql.infoschema'@'localhost'
INFORMATION_SCHEMA
max_user_connections
max_user_connections
mysql.user
Host
'usera'@'%.example.com'
User
usera
usera
usera
--old-style-user-limits
host1.example.com
usera
CREATE USER
ALTER USER
customer
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;
WITH
max_user_connections
max_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_CONNECTIONS
max_user_connections
max_user_connections
对话框,使用最大值的用户,用户的用户的连接,使用最大的用户,用户的用户的连接,使用最大的用户,用户的用户,用户的用户的连接。
user1
max_user_connections
user2
MAX_USER_CONNECTIONS
user
max_updates
max_user_connections
FLUSH USER_RESOURCES
FLUSH
PRIVILEGES
MAX_USER_CONNECTIONS
MAX_USER_CONNECTIONS
ER_TOO_MANY_USER_CONNECTIONS
ER_USER_LIMIT_REACHED
user
CREATE USER
INSERT
UPDATE
read_only
CREATE USER
ALTER USER
CONNECTION_ADMIN
SUPER
mysql.user
CREATE
USER
ALTER 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_name
password "password
"
mysql.user
user_name
Host
CHANGE MASTER TO
validate_password
mysql
[错误] mysql.user列计数错误。expected49,发现47。表可能损坏[警告] ACL表mysql.password_history失踪的一些操作可能失败。
mysql.user
sha256_password
ALTER USER
修改用户密码”(localhost,呼气;
mysql.user
mysql.user
default_password_lifetime
default_password_lifetime
N
N
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
PERSIST
GLOBAL
PASSWORD EXPIRE
CREATE USER
ALTER 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_history
password_reuse_interval
my.cnf
[mysqld]password_history=6password_reuse_interval=365
SET PERSIST password_history = 6; SET PERSIST password_reuse_interval = 365;
SET
PERSIST
GLOBAL
PASSWORD HISTORY
CREATE USER
ALTER 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.user
CREATE
USER
ALTER USER
PASSWORD REQUIRE
CURRENT
PASSWORD REQUIRE CURRENT
OPTIONAL
PASSWORD REQUIRE CURRENT
DEFAULT
password_require_current
password_require_current
password_require_current
PASSWORD
REQUIRE CURRENT DEFAULT
password_require_current
password_require_current
password_require_current
PASSWORD 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 USER
UPDATE
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
PERSIST
GLOBAL
PASSWORD
REQUIRE
CREATE
USER
ALTER 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
USER
SET PASSWORD
ALTER
USER
SET
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
REPLACE
jeffrey
REPLACE
ER_MUST_CHANGE_PASSWORD_LOGIN
内核> mysql -u myuser -p
密码 ******
错误1862(hy000):您的密码已过期。登录你要改变它使用支持过期密码的客户。
ALTER USER
SET 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_PASSWORDS
mysql_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_PASSWORDS
mysql_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_password
ER_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
libmysqlclient
MYSQL_DEFAULT_AUTH
mysql_options()
caching_sha2_password
MYSQL_DEFAULT_AUTH
CREATE
USER
ALTER
USER
CREATE USER
GRANT
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_ext
my_auth_plugin
'my_auth_string'
employee_ext
employee_ext
employee_ext
employee
employee_ext
PROXY
employee_ext
employee_ext
employee_ext
USER()
CURRENT_USER()
MySQL的> SELECT USER(), CURRENT_USER();
------------------------ -------------------- | user() | current_user() | ------------------------ -------------------- | employee_ext @本地|员工@本地| ------------------------ --------------------
CREATE USER
AS
'
auth_string
'
PROXY
GRANT
授权代理” proxied_user
' ' proxy_user
';
mysql.proxies_priv
proxy_user
proxied_user
REVOKE
撤销代理” proxied_user
“从” proxy_user
';
格兰特'a'到B的代理,C,D;格兰特'a'到D的权限授予代理;代理“”“”“”;撤销'从' B '代理,C,D;
PROXY
GRANT PROXY ... WITH GRANT
OPTION
proxied_user
proxied_user
USER()
CURRENT_USER()
proxied_user
root
PROXY ... WITH GRANT
OPTION
root
CREATE USER 'admin'@'localhost' IDENTIFIED BY 'test'; GRANT PROXY ON ''@'' TO 'admin'@'localhost' WITH GRANT OPTION;
admin
admin
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
myuser
ldap_auth
myuser_pass
ldap_auth
myuser
ldap_auth
developer
myuser
''@''
PROXY
developer
USER()
CURRENT_USER()
MySQL的> SELECT USER(), CURRENT_USER();
------------------ --------------------- | user() | current_user() | ------------------ --------------------- |中@本地|开发者@本地| ------------------ ---------------------
myuser
myuser
mysql> SELECT USER(), CURRENT_USER();
+------------------+-------------------+
| USER() | CURRENT_USER() |
+------------------+-------------------+
| myuser@localhost | manager@localhost |
+------------------+-------------------+
developer
developer
''
'%'
-- 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_plugin
some_plugin
''@'localhost'
''@'%'
mysql_native_password
check_proxy_users
check_proxy_users
check_proxy_users
mysql_native_password
mysql_native_password_proxy_users
sha256_password
sha256_password_proxy_users
PROXY
proxy_user
''@''
MySQL的> SELECT @@proxy_user;
-------------- | @ @ proxy_user | -------------- |“@”| --------------
external_user
NULL
ACCOUNT LOCK
CREATE
USER
ALTER USER
CREATE USER
ALTER USER
account_locked
SHOW CREATE USER
Locked_connects
ER_ACCOUNT_HAS_BEEN_LOCKED
用户“拒绝访问 user_name
“@” host_name
“.account也锁。
DEFINER
account_locked
account_locked
ACCOUNT UNLOCK
mysql.user
Host
user_name
host_name
CURRENT_USER()
Host
CURRENT_USER()
SQL SECURITY DEFINER
SQL SECURITY DEFINER
DEFINER
CURRENT_USER()
USER()
USER()
CURRENT_USER()
''@'localhost'
USER()
CURRENT_USER()
MySQL的> SELECT USER(), CURRENT_USER();
|十号用户(用户)的电流_ |(十)1号| | @本地主机| @本地主机|十号
'%'
CURRENT_USER()
user2
user2
USER()
CURRENT_USER()
MySQL的> SELECT USER(), CURRENT_USER();
-------------------------- --------------------- | user() | current_user() | -------------------------- --------------------- | user2@remote.example.com | user2 example.com | -------------------------- --------------------- @ %。
USER()
USER()
User
User
User
''@'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 | ----------------------------------------
REQUIRE
CREATE USER
require_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-cipher
xxx
ca.pem
server-key.pem
ssl_ca
ssl_cert
ssl_key
require_secure_transport
tls_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 ISSUER
REQUIRE 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)---------------------------
STATUS
SSL
MySQL的> \s
...ssl:不使用…
mysql> \s
...
SSL: Cipher in use is DHE-RSA-AES128-GCM-SHA256
...
--ssl
--ssl-mode
--ssl
--ssl
xxx
--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-mode
xxx
--ssl-fips-mode
OFF
ON
STRICT
--ssl-fips-mode
--ssl-fips-mode
STRICT
--ssl
PREFERRED
--ssl-mode
REQUIRED
VERIFY_CA
VERIFY_IDENTITY
DISABLED
--ssl-mode
--ssl-mode
--ssl-ca
--ssl-capath
--ssl-mode=VERIFY_CA
--ssl-mode
VERIFY_IDENTITY
--ssl-ca
--ssl-capath
--ssl-mode
VERIFY_IDENTITY
--ssl-ca
--ssl-capath
CREATE USER
ALTER USER
REQUIRE
REQUIRE
mysql --tls-version="TLSv1.1,TLSv1.2"
tls_version
sha256_password
auto_generate_certs
sha256_password_auto_generate_rsa_keys
caching_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.pem
server-key.pem
ssl_ca
ssl_cert
ssl_key
sha256_password_auto_generate_rsa_keys
caching_sha2_password_auto_generate_rsa_keys
caching_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_path
sha256_password_public_key_path
caching_sha2_password_private_key_path
caching_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-Win32
C:\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:\>openssl
OpenSSL>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_password
caching_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_version
Ssl_cipher
MySQL的> SHOW SESSION STATUS LIKE 'Ssl_version';
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ SHOW SESSION STATUS LIKE 'Ssl_cipher';
|变量name)--------------------------- _ |值|)--------------------------- | SSL RSA密码| DHE - _ AES128 - GCM - | SHA256)---------------------------
tls_version
tls_version
tls_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-version
tls_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_IP
userid=
your_userid
local_port: 3306
yourmysqlservername_or_ip
port: 3306
remote port: 3306
localhost
yourmysqlservername
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_password
caching_sha2_password
sha256_password
libmysqlclient
sha256_password
password
创建用户的sha256user”@ 'localhost'identified与sha256_password ' password
';
sha256_password
authentication_string
sha256_password
CREATE USER
sha256_password
[mysqld]default_authentication_plugin=sha256_password
sha256_password
创建用户的sha256user '@'本地主机'确定' password
';
default_authentication_plugin
mysql_native_password
创建用户的nativeuser”@ 'localhost'identified与mysql_native_password ' password
';
sha256_password
sha256_password
sha256_password_private_key_path
sha256_password_public_key_path
sha256_password_auto_generate_rsa_keys
Rsa_public_key
sha256_password
--server-public-key-path
mysql_options()
CHANGE MASTER TO
group_replication_recovery_get_public_key
sha256_password
sha256_password
private_key.pem
sha256_password_private_key_path
sha256_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
sha256user
CREATE USER
--server-public-key-path
内核> mysql --ssl-mode=DISABLED -u sha256user -p --server-public-key-path=
file_name
输入密码: password
--server-public-key-path
sha256_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_password
caching_sha2_password
caching_sha2_password
caching_sha2_password
libmysqlclient
sha2_cache_cleaner
caching_sha2_password
caching_sha2_password
password
创建用户的sha2user”@ 'localhost'identified与caching_sha2_password ' password
';
caching_sha2_password
authentication_string
caching_sha2_password
CREATE
USER
caching_sha2_password
[mysqld]default_authentication_plugin=caching_sha2_password
caching_sha2_password
创建用户的sha2user '@'本地主机'确定' password
';
default_authentication_plugin
mysql_native_password
创建用户的nativeuser”@ 'localhost'identified与mysql_native_password ' password
';
caching_sha2_password
caching_sha2_password_private_key_path
caching_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 TO
GET_MASTER_PUBLIC_KEY
group_replication_recovery_public_key_path
group_replication_recovery_get_public_key
caching_sha2_password
private_key.pem
caching_sha2_password_private_key_path
caching_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
sha2user
CREATE 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-path
caching_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_PLUGIN
Y
--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_dir
plugin_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.PLUGINS
SHOW PLUGINS
mysql>SELECT PLUGIN_NAME, PLUGIN_STATUS
FROM INFORMATION_SCHEMA.PLUGINS
WHERE PLUGIN_NAME LIKE '%pam%';
+--------------------+---------------+ | PLUGIN_NAME | PLUGIN_STATUS | +--------------------+---------------+ | authentication_pam | ACTIVE | +--------------------+---------------+
--plugin-load-add
INSTALL PLUGIN
UNINSTALL PLUGIN
authentication_pam卸载插件;
IDENTIFIED WITH
CREATE USER
CREATE USERuser
IDENTIFIED WITH authentication_pam AS 'authentication_string
';
mysql
users
data_entry
创建用户 user
IDENTIFIED 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_name
group_name
mysql_user_name
pam_service_name
group_name
mysql_user_name
group_name
=mysql_user_name
group_name
mysql_user_name
user_name
@host_name
user_name
host_name
/etc/pam.d
mysql
mysql
auth_string
CREATE USER
antonio
AUTHENTICATION_PAM_LOG
antonio
mysql
/etc/pam.d
#%PAM-1.0 auth include password-auth account include password-auth
system-login
login
@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
antonio
antonio
users
mysql
#%PAM-1.0 auth include password-auth account include password-auth
system-login
login
@include common-auth @include common-account @include common-session-noninteractive
''@''
developer
data_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
''@''
antonio
root
''@''
PROXY
mysql> SELECT USER(), CURRENT_USER(), @@proxy_user;
+-------------------+---------------------+--------------+
| USER() | CURRENT_USER() | @@proxy_user |
+-------------------+---------------------+--------------+
| antonio@localhost | developer@localhost | ''@'' |
+-------------------+---------------------+--------------+
antonio
antonio
users
data_entry
data_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_dir
plugin_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.PLUGINS
SHOW PLUGINS
mysql>SELECT PLUGIN_NAME, PLUGIN_STATUS
FROM INFORMATION_SCHEMA.PLUGINS
WHERE PLUGIN_NAME LIKE '%windows%';
+------------------------+---------------+ | PLUGIN_NAME | PLUGIN_STATUS | +------------------------+---------------+ | authentication_windows | ACTIVE | +------------------------+---------------+
--plugin-load-add
INSTALL PLUGIN
UNINSTALL PLUGIN
_插件卸载Windows认证;
IDENTIFIED WITH
CREATE USER
Rafal
Administrators
sql_admin
创建用户sql_admin确定authentication_windows ' Rafal,塔莎,管理员,“超级用户”;
authentication_windows
Rafal
sql_admin
Power
Users
sql_admin
C:\> mysql --user=sql_admin
authentication_windows
Tasha
Power
Users
sql_admin
win_user_or_group_name=mysql_user_name
win_user_or_group_name
mysql_user_name
CREATE 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_name
mysql_user_name
win_user_or_group_name
mysql_user_name
win_user_or_group_name
域\\用户。\\用户域\\组。\\ \\ wellknowngroup groupbuiltin
mysql_user_name
win_user
'win_group = sql_user1, win_user = sql_user2'
win_user
win_user
CREATE USER sql_accounting IDENTIFIED WITH authentication_windows AS 'SomeDomain\\Accounting';
SomeDomain
local_user
local_wlad
MyDomain\Developers
local_admin
local_wlad
local_admin
local_wlad
local_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_user
win_proxy
MyDomain\Developers
local_dev
local_admin
''@''
authentication_windows_use_principal_name
authentication_windows_log_level
joe
joe
plugin_dir
authentication_ldap_sasl
| |
authentication_ldap_sasl_client
| |
authentication_ldap_sasl.so
authentication_ldap_simple.so |
authentication_ldap_
XXX
libmysqlclient
authentication_ldap_simple
authentication_ldap_sasl
mysql_clear_password
authentication_pam
authentication_ldap_sasl
authentication_ldap_sasl_client
BY
CREATE USER
cn
plugin_dir
plugin_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.PLUGINS
SHOW PLUGINS
mysql>SELECT PLUGIN_NAME, PLUGIN_STATUS
FROM INFORMATION_SCHEMA.PLUGINS
WHERE 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 PLUGIN
UNINSTALL PLUGIN
卸载插件authentication_ldap_sasl;卸载插件authentication_ldap_simple;
my.cnf
authentication_ldap_simple
authentication_ldap_sasl
BY
CREATE USER
authentication_ldap_simple
mysql_clear_password
betsy
betsy_ldap
uid
uid
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 USERuser
IDENTIFIED 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 USER
betsy_ldap
betsy
CREATE USER
CREATE USERuser
IDENTIFIED 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 --password
Enter password:pwd2
(boris_ldap LDAP password)
authentication_ldap_sasl
--plugin-dir
boris
+
cn
mysql.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_simple
authentication_ldap_simple_user_search_attr
authentication_ldap_simple_group_search_attr
authentication_ldap_sasl
authentication_ldap_sasl_user_search_attr
authentication_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 --password
Enter password:pwd3
(basha LDAP password)
''@'%'
cn=accounting
basha
accounting
accounting
MySQL的> SELECT USER(), CURRENT_USER(), @@proxy_user;
----------------- ---------------------- -------------- | user() | current_user() | @ @ proxy_user | ----------------- ---------------------- -------------- |岜@本地|会计@本地|”@“%”| ----------------- ---------------------- --------------
basha
basil
内核> mysql --user=basil --password
输入密码: pwd4
(basil LDAP password)
basil
cn=front_office
basil
front_office
front_office
MySQL的> SELECT USER(), CURRENT_USER(), @@proxy_user;
----------------- ------------------------ -------------- | user() | current_user() | @ @ proxy_user | ----------------- ------------------------ -------------- |罗勒@本地| front_office @本地|”@“%”| ----------------- ------------------------ --------------
basil
mysql_no_login
plugin_dir
plugin_dir
plugin_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.PLUGINS
SHOW PLUGINS
mysql>SELECT PLUGIN_NAME, PLUGIN_STATUS
FROM INFORMATION_SCHEMA.PLUGINS
WHERE PLUGIN_NAME LIKE '%login%';
+----------------+---------------+ | PLUGIN_NAME | PLUGIN_STATUS | +----------------+---------------+ | mysql_no_login | ACTIVE | +----------------+---------------+
--plugin-load-add
INSTALL PLUGIN
UNINSTALL PLUGIN
mysql_no_login卸载插件;
IDENTIFIED WITH
CREATE USER
mysql_no_login
SQL 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;
nologin
DEFINER
mysql_no_login
——创建代理accountcreate用户proxy_base '@'本地主机'确定mysql_no_login;——授予权限的代理accountgrant…“proxy_base '@'本地主机';--允许real_user是代理的代理的代理的accountgrant proxy_base '@'本地主机' ' real_user '@'本地主机';
real_user
auth_socket
SO_PEERCRED
plugin_dir
plugin_dir
plugin_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.PLUGINS
SHOW PLUGINS
mysql>SELECT PLUGIN_NAME, PLUGIN_STATUS
FROM INFORMATION_SCHEMA.PLUGINS
WHERE PLUGIN_NAME LIKE '%socket%';
+-------------+---------------+ | PLUGIN_NAME | PLUGIN_STATUS | +-------------+---------------+ | auth_socket | ACTIVE | +-------------+---------------+
--plugin-load-add
INSTALL PLUGIN
UNINSTALL PLUGIN
auth_socket卸载插件;
authentication_string
authentication_string
CREATE USER
ALTER USER
valerie
CREATE USER 'valerie'@'localhost' IDENTIFIED WITH auth_socket;
stefanie
--user=valerie
--user
stephanie
valerie
valerie
CREATE USER
创建用户瓦莱丽'@'本地主机'确定'斯蒂芬妮' auth_socket;
CREATE
USER
ALTER USER
创建用户瓦莱丽'@'本地主机'确定auth_socket;改变用户瓦莱丽'@'本地主机'确定'斯蒂芬妮' auth_socket;
valerie
--user=valerie
plugin_dir
plugin_dir
plugin_dir
--plugin-load-add
.so
[mysqld]plugin-load-add=auth_test_plugin.so
my.cnf
.so
测试插件安装插件_ auth服务器是_ soname _ _ plugin.so测试;
INSTALL PLUGIN
INFORMATION_SCHEMA.PLUGINS
SHOW PLUGINS
mysql>SELECT PLUGIN_NAME, PLUGIN_STATUS
FROM INFORMATION_SCHEMA.PLUGINS
WHERE PLUGIN_NAME LIKE '%test_plugin%';
+--------------------+---------------+ | PLUGIN_NAME | PLUGIN_STATUS | +--------------------+---------------+ | test_plugin_server | ACTIVE | +--------------------+---------------+
--plugin-load-add
INSTALL PLUGIN
UNINSTALL PLUGIN
test_plugin_server卸载插件;
IDENTIFIED WITH
创建用户的testuser”@ 'localhost'identified与test_plugin_serverby testpassword ' ';
--user
--password
内核> mysql --user=testuser --password
输入密码: testpassword
authentication_string
authentication_string
[Note] Plugin test_plugin_server reported: 'successfully authenticated user testpassword'
authentication_ldap_sasl
xxx
authentication_ldap_simple
xxx
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_sasl
authentication_ldap_sasl_bind_root_dn
authentication_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_path
authentication_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_attr
cn
user1
mygroup
mygroup
isMemberOf
isMemberOf
member
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_size
authentication_ldap_sasl_max_pool_size
authentication_ldap_sasl_init_pool_size
authentication_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_LOG
authentication_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_attr
user1
user1
authentication_ldap_simple_auth_method_name
--authentication-ldap-simple-auth-method-name=value | |
authentication_ldap_simple_auth_method_name | |
SIMPLE |
SIMPLE
authentication_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_simple
authentication_ldap_simple_bind_root_dn
authentication_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_path
authentication_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_attr
cn
user1
mygroup
mygroup
isMemberOf
isMemberOf
member
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_size
authentication_ldap_simple_max_pool_size
authentication_ldap_simple_init_pool_size
authentication_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-FOREST
mem.local
10.172.166.100
ldap1.mem.local
10.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_attr
user1
user1
CONNECTION_CONTROL
CONNECTION_CONTROL
MYSQL_AUDIT_CONNECTION_CLASSMASK
MYSQL_AUDIT_CONNECTION_CHANGE_USER
CONNECTION_CONTROL_FAILED_LOGIN_ATTEMPTS
CONNECTION_CONTROL_FAILED_LOGIN_ATTEMPTS
CONNECTION_CONTROL
plugin_dir
plugin_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.PLUGINS
SHOW PLUGINS
mysql>SELECT PLUGIN_NAME, PLUGIN_STATUS
FROM INFORMATION_SCHEMA.PLUGINS
WHERE 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_ATTEMPTS
CONNECTION_CONTROL_FAILED_LOGIN_ATTEMPTS
CONNECTION_CONTROL
connection_control_failed_connections_threshold
connection_control_min_connection_delay
connection_control_failed_connections_threshold
connection_control_failed_connections_threshold
connection_control_min_connection_delay
connection_control_failed_connections_threshold
connection_control_min_connection_delay
connection_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
PERSIST
GLOBAL
connection_control_min_connection_delay
connection_control_max_connection_delay
connection_control_min_connection_delay
connection_control_max_connection_delay
connection_control_max_connection_delay
connection_control_min_connection_delay
CONNECTION_CONTROL
external_user@example.com
external_user@example.com
external_user@example.com
mysql.user
mysql.user
CURRENT_USER()
host1.example.com
user1@host1.example.com
user1@%.com
user1@%.example.com
user1@%
mysql.user
mysql.user
CURRENT_USER()
host2.example.com
mysql.user
错误1130(hy000):主机 host_name
“不允许连接到MySQL服务器
CONNECTION_CONTROL
Connection_control_delay_generated
connection_control_failed_connections_threshold
INFORMATION_SCHEMA
CONNECTION_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 |
N
N
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_SCHEMA
CONNECTION_CONTROL_FAILED_LOGIN_ATTEMPTS
connection_control_failed_connections_threshold
Connection_control_delay_generated
validate_password
validate_password
validate_password
validate_password
ER_NOT_VALID_PASSWORD
ALTER USER
CREATE USER
GRANT
SET 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_password
AS '*0D3CED9BEC10A777AEC23CCC353A8C08A633045E';
Query OK, 0 rows affected (0.01 sec)
validate_password.
xxx
validate_password
xxx
VALIDATE_PASSWORD_STRENGTH()
validate_password
MEDIUM
MEDIUM
validate_password.policy
LOW
validate_password.length
MEDIUM
validate_password.number_count
validate_password.mixed_case_count
validate_password.special_char_count
STRONG
validate_password.dictionary_file
validate_password
validate_password.check_user_name
validate_password
validate_password
validate_password
validate_password
plugin_dir
plugin_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_name
validate_password.policy
validate_password.check_user_name
validate_password
ALTER USER
SET PASSWORD
VALIDATE_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
STRONG
validate_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_password
validate_password.length
validate_password.mixed_case_count
validate_password.mixed_case_count | |
1 | |
0 |
validate_password
validate_password
validate_password.mixed_case_count
validate_password.number_count
validate_password.number_count | |
1 | |
0 |
validate_password
validate_password
validate_password.policy | |
1 | |
|
validate_password
validate_password.policy
validate_password.check_user_name
validate_password.policy
MEDIUM
validate_password.length
xxx
0
| |
1
| |
2
|
validate_password.special_char_count
validate_password.special_char_count | |
1 | |
0 |
validate_password
validate_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_password
validate_password
validate_password
--validate-password[=value] | |
ON | |
|
validate_password
--validate-password=FORCE_PLUS_PERMANENT
validate_password
INSTALL
PLUGIN
--plugin-load-add
validate_password
validate_password
validate_password_check_user_name
--validate-password-check-user-name | |
validate_password_check_user_name | |
ON |
validate_password
validate_password.check_user_name
validate_password_dictionary_file
validate_password_dictionary_file | |
validate_password
validate_password.dictionary_file
validate_password_length | |
8 | |
0 |
validate_password
validate_password.length
validate_password_mixed_case_count
validate_password_mixed_case_count | |
1 | |
0 |
validate_password
validate_password.mixed_case_count
validate_password_number_count
validate_password_number_count | |
1 | |
0 |
validate_password
validate_password.number_count
validate_password_policy | |
1 | |
|
validate_password
validate_password.policy
validate_password_special_char_count
validate_password_special_char_count | |
1 | |
0 |
validate_password
validate_password.special_char_count
validate_password
validate_password
validate_password_dictionary_file_last_parsed
validate_password
validate_password.dictionary_file_last_parsed
validate_password_dictionary_file_words_count
validate_password
validate_password.dictionary_file_words_count
validate_password
validate_password
validate_password
validate_password
安装组件:组件文件_ _密码/验证;
validate_password
xxx
[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_dir
plugin_dir
keyring_file
keyring_file
.so
InnoDB
--early-plugin-load
my.cnf
[mysqld] early-plugin-load=keyring_file.so
keyring_file
keyring_okv
keyring_aws
INFORMATION_SCHEMA.PLUGINS
SHOW PLUGINS
mysql>SELECT PLUGIN_NAME, PLUGIN_STATUS
FROM INFORMATION_SCHEMA.PLUGINS
WHERE PLUGIN_NAME LIKE 'keyring%';
+--------------+---------------+ | PLUGIN_NAME | PLUGIN_STATUS | +--------------+---------------+ | keyring_file | ACTIVE | +--------------+---------------+
InnoDB
InnoDB
--early-plugin-load
--plugin-load
--plugin-load-add
INSTALL PLUGIN
--plugin-load
--plugin-load-add
INSTALL
PLUGIN
mysql.plugin
InnoDB
keyring_file
keyring_file
keyring_file
keyring_file
keyring_file
--early-plugin-load
keyring_file_data
my.cnf
[mysqld] early-plugin-load=keyring_file.so keyring_file_data=/usr/local/mysql/mysql-keyring/keyring
keyring_file
keyring_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_file
keyring_encrypted_file
keyring_encrypted_file
--early-plugin-load
keyring_encrypted_file_password
keyring_encrypted_file_data
my.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_file
keyring_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_okv
keyring_okv
keyring_okv
keyring_okv_conf_dir
keyring_okv
[警告]插件keyring_okv报道:“keyring_okv到beinitialized,请点keyring_okv_conf_dir变量一个directorycontaining Oracle密钥库的配置文件和SSL的材料
keyring_okv_conf_dir
okvclient.ora
ssl
cert.pem
ssl
okvclient.ora
keyring_okv
keyring_okv
root
cd /usr/local mysqlmkdir MySQL的钥匙圈okvchmod 750 MySQL的钥匙圈okvchown mysql mysql的钥匙圈钥匙圈okvchgrp OKV
keyring_okv
--early-plugin-load
keyring_okv_conf_dir
my.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_num
STANDBY_SERVER=host_ip
:port_num
keyring_okv
STANDBY_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_num
STANDBY_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.pem
key.pem
key.pem
ssl
keyring_aws
keyring_aws
keyring_aws
keyring_aws
keyring_aws
keyring_aws
keyring_aws_rotate_keys()
keyring_aws
keyring_aws_cmk_id
SET
GLOBAL
/usr/local/mysql/mysql-keyring/keyring_aws_conf
shell>cd /usr/local/mysql
shell>mkdir mysql-keyring
shell>chmod 750 mysql-keyring
shell>chown mysql mysql-keyring
shell>chgrp mysql mysql-keyring
keyring_aws_conf_file
keyring_aws
wwwwwwwwwwwwwEXAMPLE
wwwwwwwwwwwwwEXAMPLE xxxxxxxxxxxxx/yyyyyyy/zzzzzzzzEXAMPLEKEY
keyring_aws
--early-plugin-load
keyring_aws_cmk_id
keyring_aws_conf_file
keyring_aws_data_file
my.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 PLUGIN
keyring_aws
--early-plugin-load
UNINSTALL PLUGIN
INSTALL PLUGIN
UNINSTALL
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_file
keyring_file_data
--defaults-file
mysql
isabel
isabel
root
--user=
user_name
user_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_operations
ENCRYPTION_KEY_ADMIN
SYSTEM_VARIABLES_ADMIN
SUPER
keyring_operations
keyring_operations
keyring_operations
keyring_operations
keyring_operations
keyring_operations
keyring_operations=OFF
keyring_operations=ON
keyring_operations=ON
keyring_encrypted_file |
| |
keyring_file |
| |
keyring_okv | AES | |
keyring_aws | AES |
keyring_udf
keyring_okv
keyring_udf
keyring_udf
plugin_dir
plugin_dir
keyring_udf
.dll
keyring_udf
INSTALL PLUGIN
CREATE 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_udf
UNINSTALL PLUGIN
DROP 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 | ------------------------------------------------------
EXECUTE
CURRENT_USER()
EXECUTE
DEFINER
EXECUTE
DEFINER
SharedKey
EXECUTE
'root'@'localhost'
MySQL的> CREATE SCHEMA key_schema;
MySQL的> CREATE DEFINER = 'root'@'localhost'
FUNCTION key_schema.get_shared_key()
RETURNS BLOB READS SQL DATA
RETURN 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_user
EXECUTE
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_key
TO '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_aws
SUPER
keyring_aws_rotate_cmk()
keyring_aws_cmk_id
INTEGER keyring_aws_rotate_cmk()
NULL
keyring_aws_rotate_keys()
keyring_aws
SUPER
keyring_aws_rotate_keys()
keyring_aws_data_file
keyring_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-load
name
=
plugin_library
plugin_library
name
plugin_library
plugin_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_conf
keyring_file_data
--keyring-aws-data-file | |
keyring_aws_data_file | |
platform specific |
keyring_aws
keyring_aws_data_file
keyring_aws
keyring_aws_data
keyring_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_file
keyring_encrypted_file_data
keyring_encrypted_file
keyring_encrypted
INSTALL_LAYOUT
INSTALL_MYSQLKEYRINGDIR
INSTALL_LAYOUT | keyring_encrypted_file_data |
---|---|
DEB
SLES
| /var/lib/mysql-keyring/keyring_encrypted |
keyring/keyring_encrypted CMAKE_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_file
keyring_encrypted_file_data
keyring_encrypted_file
keyring_encrypted_file_data
keyring_encrypted_file_password
--keyring-encrypted-file-password=password | |
keyring_encrypted_file_password | |
keyring_encrypted_file
keyring_encrypted_file_password
SHOW VARIABLES
global_variables
--keyring-file-data=file_name | |
keyring_file_data | |
platform specific |
keyring_file
keyring_file
keyring_file_data
keyring_file
keyring
INSTALL_LAYOUT
INSTALL_MYSQLKEYRINGDIR
INSTALL_LAYOUT | keyring_file_data |
---|---|
DEB
SLES
| /var/lib/mysql-keyring/keyring |
keyring/keyring CMAKE_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_file
keyring_file_data
keyring_file
InnoDB
keyring_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_dir
keyring_okv_conf_dir
keyring_operations | |
ON |
ENCRYPTION_KEY_ADMIN
SYSTEM_VARIABLES_ADMIN
SUPER
audit_log
audit.log
audit_log_file
audit_log_format
SELECT NAME FROM performance_schema.setup_instruments WHERE NAME LIKE '%/alog/%';
audit_log
mysql
AUDIT_ADMIN
audit_log
plugin_dir
plugin_dir
share
audit_log_filter_win_install.sql
audit_log_filter_linux_install.sql
shell>mysql -u root -p < audit_log_filter_linux_install.sql
Enter password:(enter root password here)
USER
audit_log_user
Host
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.PLUGINS
SHOW PLUGINS
mysql>SELECT PLUGIN_NAME, PLUGIN_STATUS
FROM INFORMATION_SCHEMA.PLUGINS
WHERE PLUGIN_NAME LIKE 'audit%';
+-------------+---------------+ | PLUGIN_NAME | PLUGIN_STATUS | +-------------+---------------+ | audit_log | ACTIVE | +-------------+---------------+
--audit-log
[mysqld] audit-log=FORCE_PLUS_PERMANENT
--audit-log
FORCE_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.log
audit_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审计已关闭
Audit
Change
user
Connect Out
Create DB
Debug
Drop
DB
Fetch
Init DB
Long Data
Ping
Processlist
Quit
Register Slave
Set option
Sleep
Table
Dump
"Audit"
COM_
xxx
"Create DB"
COM_CREATE_DB
RECORD_ID
SEQ_TIMESTAMP
YYYY-MM-DD
hh:mm:ss
RECORD_ID="12_2017-10-16T14:25:00"
TIMESTAMP
YYYY-MM-DD
Thh:mm:ss
UTC
TIMESTAMP="2017-10-16T14:25:32
UTC"
<AUDIT_RECORD>
COMMAND_CLASS
COMMAND_CLASS="drop_table"
statement/sql/
xxx
xxx
select
DROP
TABLE
SELECT
选择替换(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/IP
Socket
Shared
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_CODE
STATUS_CODE
mysql_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审计已关闭
Audit
Change
user
Connect Out
Create DB
Debug
Drop
DB
Fetch
Init DB
Long Data
Ping
Processlist
Quit
Register Slave
Set option
Sleep
Table
Dump
Audit
COM_
xxx
Create DB
COM_CREATE_DB
<RECORD_ID>
SEQ_TIMESTAMP
YYYY-MM-DD
hh:mm:ss
<RECORD_ID>12_2017-10-16T14:06:33</RECORD_ID>
<TIMESTAMP>
YYYY-MM-DD
Thh: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/
xxx
xxx
select
DROP
TABLE
SELECT
选择替换(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/IP
Socket
Shared
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_CODE
STATUS_CODE
mysql_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=JSON
JSON
JSON
【{“时间戳”:“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_id
login
{ "timestamp": "2018-01-15 14:28:20", "id": 3, "class": "audit", "event": "shutdown", "connection_id": 0, "shutdown_data": { "server_id": 1 } }
connection_id
login
{ "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 | connect
disconnect |
general | status |
table_access_data | read
insert
|
connection_data
connection_type
db
connection
"connection_data": { "connection_type": "ssl", "status": 0, "db": "test" }
connection_id
CONNECTION_ID()
"connection_id": 5
event
class
"event": "connect"
general_data
command
query
class
"general_data": { "command": "Query", "sql_command": "show_variables", "query": "SHOW VARIABLES", "status": 0 }
id
"id": 2
timestamp
timestamp
login
user
ip
"login": { "user": "root", "os": "", "ip": "::1", "proxy": "" }
shutdown_data
server_id
event
shutdown
"shutdown_data": { "server_id": 1 }
startup_data
server_id
mysql_version
class
audit
"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
db
query
class
"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"
timestamp
timestamp
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/ip
socket
shared_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/
xxx
xxx
select
DROP
TABLE
SELECT
选择替换(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.log
YYYYMMDD
Thhmmss
audit_log_format
audit_log_format
audit_log_file
audit_log_compression
GZIP
audit_log_encryption
AES
audit_log_encryption_password_set()
audit.20180115T140633.log.enc
YYYYMMDD
hhmmss
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_strategy
PERFORMANCE
sync()
audit_log_buffer_size
audit_log_strategy
PERFORMANCE
audit_log_rotate_on_size
audit_log_flush
audit_log_rotate_on_size=0
audit_log_flush
audit.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_size
audit_log_flush
audit_log_rotate_on_size
audit.log
YYYYMMDD
Thhmmss
audit_log_file
audit_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()
JSON
JSON
[ { "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_size
audit_log_read_buffer_size
audit_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
JSON
JSON
%
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');
mysql
INSERT
UPDATE
DELETE
SELECT audit_log_filter_flush();
audit_log_filter_id
MySQL的> SELECT @@audit_log_filter_id;
----------------------- | @ @ audit_log_filter_id | ----------------------- | 2 | -----------------------
JSON
JSON
actions
{“过滤器”: actions
}
log
{“过滤”:{“日志”:真} }
log
false
{ "filter": { } }
log
event
log
log
class
false
event
class
{ "filter": { "class": { "name": "connection" } } }
name
general
connection
{ "filter": { "log": false, "class": { "log": true, "name": "connection" } } }
class
JSON
{“过滤”:{“类”:[ {“名字”:“连接”},{“名字”:“一般”},{“名字”:“table_access”} } } ]
{ "filter": { "class": [ { "name": [ "connection", "general", "table_access" ] } ] } }
event
event
{“过滤”:{“类”:[ {“名字”:“连接”、“事件”:[ {“名字”:“连接”},{“名字”:“断开”}】},{“名字”:“一般”},{“名字”:“table_access”、“事件”:[ {“名字”:“插入”},{“名字”:“删除”},{“名字”:“更新”} } } } ] ]
event
event
“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 | SELECT INSERT
INTO ... SELECT |
table_access | delete | DELETE TRUNCATE TABLE |
table_access | insert | INSERT REPLACE |
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 |
connect
connection
{ "filter": { "log": false, "class": [ { "name": "connection", "event": [ { "name": "connect", "log": true }, { "name": "disconnect", "log": true } ] }, { "name": "general", "log": true } ] } }
general
{“过滤”:{“日志”:真的,“阶级”:{“名字”:“一般”,“日志”:假} } }
change_user
table_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.str
Execute
Change user
general_command.str
Execute
alter_db
admin_commands
MySQL的> SELECT NAME FROM performance_schema.setup_instruments
WHERE 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
event
abort
abort
"event": { "name":qualifying event subclass names
"abort":condition
}
name
condition
condition
false
{“过滤”:{“类”:{“名字”:“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
and
not
{ "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_value
audit_log_connection_policy
audit_log_
xxx
_policySHOW
VARIABLES
variable
audit_log_connection_policy_value
audit_log_connection_policy
audit_log_connection_policy
0
| NONE |
1
| ERRORS |
2
| ALL |
"::
xxx
"
audit_log_policy_value
audit_log_policy
audit_log_policy
0
| NONE |
1
| LOGINS |
2
| ALL |
3
| QUERIES |
"::
xxx
"
audit_log_statement_policy_value
audit_log_statement_policy
audit_log_statement_policy
0
| NONE |
1
| ERRORS |
2
| ALL |
"::
xxx
"
log
name
{ "filter": { "class": { "name": "general", "event": { "name": "status", "log": { "function": { "name": "find_in_include_list", "args": [ { "string": [ { "field": "user.str" }, { "string": "@"}, { "field": "host.str" } ] } ] } } } } } }
name
general
audit_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" } } ] } } } } } }
activate
activate
ref
main
update
update
table_access
temp_2
general
main
temp_1
UPDATE temp_1, temp_3 SET temp_1.a=21, temp_3.a=23;
table_access
status
id
audit_log_filter_id
audit_log
audit_log_include_accounts
audit_log_exclude_accounts
NULL
user_name
host_name
audit_log_include_accounts
audit_log_exclude_accounts
user1
audit_log_include_accounts
SET GLOBAL audit_log_include_accounts = 'user1@localhost,user2@localhost';
audit_log_include_accounts
audit_log_exclude_accounts
audit_log_include_accounts
audit_log_exclude_accounts
audit_log_exclude_accounts
audit_log_include_accounts
audit_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 VARIABLES
SELECT
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
ALL
NONE
SET GLOBAL audit_log_statement_policy = ALL;SET GLOBAL audit_log_connection_policy = ERRORS;
audit_log_policy
audit_log_connection_policy
audit_log_statement_policy
LOGINS
NONE
audit_log_policy
audit_log_policy
audit_log_connection_policy
audit_log_statement_policy
audit_log_policy
audit_log_connection_policy
audit_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@localhost
user1
HOST
user1@localhost
localhost
FILTERNAME
audit_log_filter
OK
message
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()
INSERT
UPDATE
DELETE
audit_log_filter_flush()
audit_log_filter_flush()
STRING audit_log_filter_flush()
OK
message
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
OK
message
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_name
user_name
host_name
OK
message
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
definition
JSON
OK
message
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_name
user_name
host_name
filter_name
OK
message
mysql> SELECT audit_log_filter_set_user('user1@localhost', 'SomeFilter');
+------------------------------------------------------------+
| audit_log_filter_set_user('user1@localhost', 'SomeFilter') |
+------------------------------------------------------------+
| OK |
+------------------------------------------------------------+
audit_log_read()
JSON
JSON
JSON
audit_log_read()
JSON
audit_log_read()
JSON
audit_log_read()
audit_log_read_bookmark()
STRING audit_log_read([STRING arg])
arg
JSON
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
JSON
id
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_log
INSTALL
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_policy
audit_log_policy
audit_log_current_session | |
depends on filtering policy |
audit_log_include_accounts
audit_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.log
audit.jsson
audit_log_file
audit_log_file
audit_log_file
audit_log_filter_id | |
audit_log_flush | |
OFF |
ON
audit_log_rotate_on_size
--audit-log-format=value | |
audit_log_format | |
NEW | |
|
OLD
JSON
--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_policy
audit_log_connection_policy
audit_log_statement_policy
audit_log_policy
--audit-log-read-buffer-size=# | |
audit_log_read_buffer_size | |
32768 | |
1048576 | |
32768 | |
1024 | |
4194304 |
audit_log_read()
audit_log_read_buffer_size
audit_log_read_buffer_size
--audit-log-rotate-on-size=N | |
audit_log_rotate_on_size | |
0 |
audit_log_rotate_on_size
audit_log_flush
audit_log_rotate_on_size
audit_log_rotate_on_size
--audit-log-statement-policy=value | |
audit_log_statement_policy | |
ALL | |
|
ALL | |
ERRORS | |
NONE |
audit_log_statement_policy
audit_log_policy
--audit-log-strategy=value | |
audit_log_strategy | |
ASYNCHRONOUS | |
|
ASYNCHRONOUS
PERFORMANCE
SEMISYNCHRONOUS
SYNCHRONOUS
audit_log_buffer_size
Audit_log_current_size
Audit_log_total_size
LOAD DATA
INFILE
MYSQL_FIREWALL
MYSQL_FIREWALL_USERS
INFORMATION_SCHEMA
firewall_users
mysql
sp_set_firewall_mode()
FIREWALL_ADMIN
FIREWALL_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 |
+---------------------+-------+
mysql
DROP 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
USER
GRANT
@
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_USERS
WHERE USERHOST = 'fwuser@localhost';
----------- |模式| ----------- |记录| ----------- MySQL > SELECT RULE FROM INFORMATION_SCHEMA.MYSQL_FIREWALL_WHITELIST
WHERE 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_granted
SHOW TABLES
INFORMATION_SCHEMA
INFORMATION_SCHEMA
INFORMATION_SCHEMA.MYSQL_FIREWALL_USERS
USERHOST
user_name
@host_name
MODE
OFF
PROTECTING
RESET
INFORMATION_SCHEMA.MYSQL_FIREWALL_WHITELIST
USERHOST
RULE
ID
CALL mysql.sp_set_firewall_mode(user
,mode
);
sp_reload_firewall_rules(
user
)
mysql.firewall_whitelist
user
user_name
host_name
CALL mysql.sp_reload_firewall_rules('fwuser@localhost');
RESET
OFF
sp_set_firewall_mode()
sp_reload_firewall_rules()
sp_set_firewall_mode(
user
,
mode
)
mysql_firewall_mode
user
user_name
host_name
mode
OFF
DETECTING
PROTECTING
RECORDING
RESET
RECORDING
OFF
mysql.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_mode
ON
STRICT
ON
ssl_fips_mode
--ssl-fips-mode
RC4-MD5
CREATE USER
ALTER USER
require_secure_transport