天天看點

Mysql 安全登陸工具 mysql_config_editor

Mysql 安全登陸工具 mysql_config_editor

mysql_config_editor

幫助資訊請檢視

man mysql_config_editor 或 mysql_config_editor -? 或 mysql_config_editor set -?

該工具會在使用者家目錄生成二進制檔案:.mylogin.cnf

該檔案格式由選項組組成,每個選項組被稱為login path ,僅包含特定選項: host, user, password, port and socket 用于使用者驗證。

用法:

mysql_config_editor set [command options] Sets user name/password/host name/socket/port for a given login path (section).

mysql_config_editor remove [command options] Remove a login path from the login file.

mysql_config_editor print [command options] Print all the options for a specified login path.

mysql_config_editor reset [command options] Deletes the contents of the login file.

設定 login path

複制代碼

[root@mysql1 ~]# mysql_config_editor set -?

-h, --host=name Host name to be entered into the login file.

-G, --login-path=name Name of the login path to use in the login file. (Default: client)

-p, --password Prompt for password to be entered into the login file.

-u, --user=name User name to be entered into the login file.

-S, --socket=name Socket path to be entered into login file.

-P, --port=name Port number to be entered into login file.

如:

mysql_config_editor set -G mypath -u root -p -S /u01/data/mysql5.7.25/mysql.sock

mysql_config_editor set -G user1 -u user1 -p -S /u01/data/mysql5.7.25/mysql.sock

顯示 login path

mysql_config_editor print --all

mysql_config_editor print -G user1

[root@mysql1 ~]# mysql_config_editor print --all

[client] # 預設 login path

[mypath]

user = root

password = *

socket = /u01/data/mysql5.7.25/mysql.sock

[mypath1]

[user1]

user = user1

删除 login path

mysql_config_editor remove -G user1

[root@mysql1 ~]# mysql_config_editor remove -G user1

[client]

重置 login file

mysql_config_editor reset

[root@mysql1 ~]# mysql_config_editor reset

[root@mysql1 ~]# mysql_config_editor print --all # 檔案已被清空

使用 login path

mysql --login-path=mypath

mysqladmin --login-path=mypath

[root@mysql1 ~]# mysqladmin --login-path=mypath status

Uptime: 11918 Threads: 1 Questions: 18 Slow queries: 0 Opens: 106 Flush tables: 1 Open tables: 99 Queries per second avg: 0.001

原文位址

https://www.cnblogs.com/plluoye/p/10629180.html

繼續閱讀