阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

MySQL 安全登陆工具 mysql_config_editor

234次阅读
没有评论

共计 2052 个字符,预计需要花费 6 分钟才能阅读完成。

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]
user = root
password = *****
socket = /u01/data/mysql5.7.25/mysql.sock
[user1]
user = user1
password = *****
socket = /u01/data/mysql5.7.25/mysql.sock

删除 login path

mysql_config_editor remove -G user1

[root@mysql1 ~]# mysql_config_editor remove -G user1
[root@mysql1 ~]# mysql_config_editor print –all
[client]
[mypath]
user = root
password = *****
socket = /u01/data/mysql5.7.25/mysql.sock
[mypath1]
user = root
password = *****
socket = /u01/data/mysql5.7.25/mysql.sock

重置 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

 

正文完
星哥玩云-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-22发表,共计2052字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中