root@server-mysql bin]# ./mysql_config_editor set --login-path=client --user=root --password --socket=/tmp/mysql.sock5Enter password: [root@server-mysql bin]# ./mysql_config_editor set --login-path=client1 --user=root --host=127.0.0.1 --password --port=3310Enter password:
打印所有已经写入的账号
[root@server-mysql bin]# ./mysql_config_editor print --all[client]user = rootpassword = *****socket = /tmp/mysql.sock5[client1]user = rootpassword = *****host = 127.0.0.1port = 3310
登陆:
[root@server-mysql bin]# ./mysql --login-path=client
账号写入位置:该文件已经加密, 不能被偷看
[root@server-mysql ~]# find / |grep .mylogin.cnf /root/.mylogin.cnf
mysql_config_editor
标签:
小编还为您整理了以下内容,可能对您也有帮助:
mysql_config_editor密码带#号
mysql_config_editor是一个MySQL配置文件管理工具,用于管理MySQL的登录认证信息。在使用该工具时,如果你的登录密码中带有“#”符号,则可能会导致程序报错或无法正常工作。
解决方案一般为在密码中加上转义字符“\”,使其不被误认为是注释符号。例如,如果你的密码为“mypassword#123”,则需要将其改为“mypassword\#123”。
另外一种解决方案是将密码保存在环境变量中,避免在命令行中直接输入密码。这样不仅能够保护密码的安全性,还能够避免因特殊字符引起的问题。
总之,遇到带有特殊字符的密码,我们需要注意字符转义和环境变量等处理方式,以确保配置文件管理工具能够正常工作。
mysql 5.6新增了什么功能
[mysqld] plugin-load=audit_log.so
[mysqld] plugin-load=audit_log.so audit-log=FORCE_PLUS_PERMANENT
mysql> INSTALL PLUGIN audit_log SONAME 'audit_log.so';
Value | Description |
---|---|
ALL | Log all connection events |
ERRORS | Log only failed connection events |
NONE | Do not log connection events |
Value | Description |
---|---|
ALL | Log all events |
LOGINS | Log only login events |
QUERIES | Log only query events |
NONE | Log nothing (disable the audit stream |
Value | Description |
---|---|
ALL | Log all statement events |
ERRORS | Log only failed statement events |
NONE | Do not log statement events |
Value | Meaning |
---|---|
ASYNCHRONOUS | Log asynchronously, wait for space in output buffer |
PERFORMANCE | Log asynchronously, drop request if insufficient space in output buffer |
SEMISYNCHRONOUS | Log synchronously, permit caching by operating system |
SYNCHRONOUS | Log synchronously, call sync() after each request |
<?xml version="1.0" encoding="UTF-8"?><AUDIT> <AUDIT_RECORD> <TIMESTAMP>2013-09-17T15:03:24 UTC</TIMESTAMP> <RECORD_ID>1_2013-09-17T15:03:24</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>x86_64-osx10.6</OS_VERSION> <MYSQL_VERSION>5.7.2-m12-log</MYSQL_VERSION> </AUDIT_RECORD> <AUDIT_RECORD> <TIMESTAMP>2013-09-17T15:03:40 UTC</TIMESTAMP> <RECORD_ID>2_2013-09-17T15:03:24</RECORD_ID> <NAME>Connect</NAME> <CONNECTION_ID>2</CONNECTION_ID> <STATUS>0</STATUS> <STATUS_CODE>0</STATUS_CODE> <USER>root</USER> <OS_LOGIN></OS_LOGIN> <HOST>localhost</HOST> <IP>127.0.0.1</IP> <COMMAND_CLASS>connect</COMMAND_CLASS> <PRIV_USER>root</PRIV_USER> <PROXY_USER></PROXY_USER> <DB>test</DB> </AUDIT_RECORD>... <AUDIT_RECORD> <TIMESTAMP>2013-09-17T15:03:41 UTC</TIMESTAMP> <RECORD_ID>4_2013-09-17T15:03:24</RECORD_ID> <NAME>Query</NAME> <CONNECTION_ID>2</CONNECTION_ID> <STATUS>0</STATUS> <STATUS_CODE>0</STATUS_CODE> <USER>root[root] @ localhost [127.0.0.1]</USER> <OS_LOGIN></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>2013-09-17T15:03:41 UTC</TIMESTAMP> <RECORD_ID>5_2013-09-17T15:03:24</RECORD_ID> <NAME>Query</NAME> <CONNECTION_ID>2</CONNECTION_ID> <STATUS>0</STATUS> <STATUS_CODE>0</STATUS_CODE> <USER>root[root] @ localhost [127.0.0.1]</USER> <OS_LOGIN></OS_LOGIN> <HOST>localhost</HOST> <IP>127.0.0.1</IP> <COMMAND_CLASS>create_table</COMMAND_CLASS> <SQLTEXT>CREATE TABLE t (i INT)</SQLTEXT> </AUDIT_RECORD>... <AUDIT_RECORD> <TIMESTAMP>2013-09-17T15:03:41 UTC</TIMESTAMP> <RECORD_ID>7_2013-09-17T15:03:24</RECORD_ID> <NAME>Quit</NAME> <CONNECTION_ID>2</CONNECTION_ID> <STATUS>0</STATUS> <STATUS_CODE>0</STATUS_CODE> <USER></USER> <OS_LOGIN></OS_LOGIN> <HOST></HOST> <IP></IP> <COMMAND_CLASS>connect</COMMAND_CLASS> </AUDIT_RECORD>... <AUDIT_RECORD> <TIMESTAMP>2013-09-17T15:03:47 UTC</TIMESTAMP> <RECORD_ID>9_2013-09-17T15:03:24</RECORD_ID> <NAME>Shutdown</NAME> <CONNECTION_ID>3</CONNECTION_ID> <STATUS>0</STATUS> <STATUS_CODE>0</STATUS_CODE> <USER>root[root] @ localhost [127.0.0.1]</USER> <OS_LOGIN></OS_LOGIN> <HOST>localhost</HOST> <IP>127.0.0.1</IP> <COMMAND_CLASS></COMMAND_CLASS> </AUDIT_RECORD> <AUDIT_RECORD> <TIMESTAMP>2013-09-17T15:03:47 UTC</TIMESTAMP> <RECORD_ID>10_2013-09-17T15:03:24</RECORD_ID> <NAME>Quit</NAME> <CONNECTION_ID>3</CONNECTION_ID> <STATUS>0</STATUS> <STATUS_CODE>0</STATUS_CODE> <USER></USER> <OS_LOGIN></OS_LOGIN> <HOST></HOST> <IP></IP> <COMMAND_CLASS>connect</COMMAND_CLASS> </AUDIT_RECORD> <AUDIT_RECORD> <TIMESTAMP>2013-09-17T15:03:49 UTC</TIMESTAMP> <RECORD_ID>11_2013-09-17T15:03:24</RECORD_ID> <NAME>NoAudit</NAME> <SERVER_ID>1</SERVER_ID> </AUDIT_RECORD></AUDIT>
版权声明:本文为博主原创文章,未经博主允许不得转载。
Mysql5.6审计功能
标签:数据库 mysql 安全
mysql 5.6新增了什么功能
[mysqld] plugin-load=audit_log.so
[mysqld] plugin-load=audit_log.so audit-log=FORCE_PLUS_PERMANENT
mysql> INSTALL PLUGIN audit_log SONAME 'audit_log.so';
Value | Description |
---|---|
ALL | Log all connection events |
ERRORS | Log only failed connection events |
NONE | Do not log connection events |
Value | Description |
---|---|
ALL | Log all events |
LOGINS | Log only login events |
QUERIES | Log only query events |
NONE | Log nothing (disable the audit stream |
Value | Description |
---|---|
ALL | Log all statement events |
ERRORS | Log only failed statement events |
NONE | Do not log statement events |
Value | Meaning |
---|---|
ASYNCHRONOUS | Log asynchronously, wait for space in output buffer |
PERFORMANCE | Log asynchronously, drop request if insufficient space in output buffer |
SEMISYNCHRONOUS | Log synchronously, permit caching by operating system |
SYNCHRONOUS | Log synchronously, call sync() after each request |
<?xml version="1.0" encoding="UTF-8"?><AUDIT> <AUDIT_RECORD> <TIMESTAMP>2013-09-17T15:03:24 UTC</TIMESTAMP> <RECORD_ID>1_2013-09-17T15:03:24</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>x86_64-osx10.6</OS_VERSION> <MYSQL_VERSION>5.7.2-m12-log</MYSQL_VERSION> </AUDIT_RECORD> <AUDIT_RECORD> <TIMESTAMP>2013-09-17T15:03:40 UTC</TIMESTAMP> <RECORD_ID>2_2013-09-17T15:03:24</RECORD_ID> <NAME>Connect</NAME> <CONNECTION_ID>2</CONNECTION_ID> <STATUS>0</STATUS> <STATUS_CODE>0</STATUS_CODE> <USER>root</USER> <OS_LOGIN></OS_LOGIN> <HOST>localhost</HOST> <IP>127.0.0.1</IP> <COMMAND_CLASS>connect</COMMAND_CLASS> <PRIV_USER>root</PRIV_USER> <PROXY_USER></PROXY_USER> <DB>test</DB> </AUDIT_RECORD>... <AUDIT_RECORD> <TIMESTAMP>2013-09-17T15:03:41 UTC</TIMESTAMP> <RECORD_ID>4_2013-09-17T15:03:24</RECORD_ID> <NAME>Query</NAME> <CONNECTION_ID>2</CONNECTION_ID> <STATUS>0</STATUS> <STATUS_CODE>0</STATUS_CODE> <USER>root[root] @ localhost [127.0.0.1]</USER> <OS_LOGIN></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>2013-09-17T15:03:41 UTC</TIMESTAMP> <RECORD_ID>5_2013-09-17T15:03:24</RECORD_ID> <NAME>Query</NAME> <CONNECTION_ID>2</CONNECTION_ID> <STATUS>0</STATUS> <STATUS_CODE>0</STATUS_CODE> <USER>root[root] @ localhost [127.0.0.1]</USER> <OS_LOGIN></OS_LOGIN> <HOST>localhost</HOST> <IP>127.0.0.1</IP> <COMMAND_CLASS>create_table</COMMAND_CLASS> <SQLTEXT>CREATE TABLE t (i INT)</SQLTEXT> </AUDIT_RECORD>... <AUDIT_RECORD> <TIMESTAMP>2013-09-17T15:03:41 UTC</TIMESTAMP> <RECORD_ID>7_2013-09-17T15:03:24</RECORD_ID> <NAME>Quit</NAME> <CONNECTION_ID>2</CONNECTION_ID> <STATUS>0</STATUS> <STATUS_CODE>0</STATUS_CODE> <USER></USER> <OS_LOGIN></OS_LOGIN> <HOST></HOST> <IP></IP> <COMMAND_CLASS>connect</COMMAND_CLASS> </AUDIT_RECORD>... <AUDIT_RECORD> <TIMESTAMP>2013-09-17T15:03:47 UTC</TIMESTAMP> <RECORD_ID>9_2013-09-17T15:03:24</RECORD_ID> <NAME>Shutdown</NAME> <CONNECTION_ID>3</CONNECTION_ID> <STATUS>0</STATUS> <STATUS_CODE>0</STATUS_CODE> <USER>root[root] @ localhost [127.0.0.1]</USER> <OS_LOGIN></OS_LOGIN> <HOST>localhost</HOST> <IP>127.0.0.1</IP> <COMMAND_CLASS></COMMAND_CLASS> </AUDIT_RECORD> <AUDIT_RECORD> <TIMESTAMP>2013-09-17T15:03:47 UTC</TIMESTAMP> <RECORD_ID>10_2013-09-17T15:03:24</RECORD_ID> <NAME>Quit</NAME> <CONNECTION_ID>3</CONNECTION_ID> <STATUS>0</STATUS> <STATUS_CODE>0</STATUS_CODE> <USER></USER> <OS_LOGIN></OS_LOGIN> <HOST></HOST> <IP></IP> <COMMAND_CLASS>connect</COMMAND_CLASS> </AUDIT_RECORD> <AUDIT_RECORD> <TIMESTAMP>2013-09-17T15:03:49 UTC</TIMESTAMP> <RECORD_ID>11_2013-09-17T15:03:24</RECORD_ID> <NAME>NoAudit</NAME> <SERVER_ID>1</SERVER_ID> </AUDIT_RECORD></AUDIT>
版权声明:本文为博主原创文章,未经博主允许不得转载。
Mysql5.6审计功能
标签:数据库 mysql 安全
cmd直接执行sql脚本
以 mysql -h localhost -uroot -ppassword 方式直接将密码写入快捷方式,
登陆可以成功,但是如果使用 -e 参数执行语句,会出现
Warning: Using a password on the command line interface can be insecure 错误 ,
在MySQL 5.6.6之后可以使用 mysql_config_editor ,它可以把账户密码写入 */.mylogin.cnf 并加密
登入 MySQL Serverbin 文件夹,执行
mysql_config_editor set --login-path=xxx --host=127.0.0.1 --user=root --password
--login-path 的值只是一个名字,可以随便写,
回车,然后输入密码,就完成了账户信息的写入
mysql_config_editor print --all
mysql --login-path=xxx
试一下,应该可以登入了
创建快捷方式,快捷方式的
目标:
"C:Program FilesMySQLMySQL Server 5.7binmysql.exe" "--defaults-file=C:ProgramDataMySQLMySQL Server 5.7my.ini" --login-path=try -e "SOURCE C:/Users/Desktop/main.sql;"
注意 -e 后面 路径中的反斜杠,写错了是无法运行的
起始位置:
"C:Program FilesMySQLMySQL Server 5.7bin"
mysql,为什么我用命令行添加表之后,总是显示有一个警告?这警告是什么?怎么看?
能不能把那个警告的信息给出来?
你还是没有把具体的warning信息给出
1 warning是说有1个错误
如果没有列出错误的具体信息,那也没有办法了.
可能你是输入的命令有错误