您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

关于Oracle和MySQL中的无密码登录

2025/11/3 10:53:26发布45次查看
在oracle和mysql中都有相应的解决方案,大道至简,这个功能的目的都是类似的。在oracle中可以通过设置wallet来实现,在10g版本开
无密码登录在一定程度上能够简化流程,对于密码敏感,但是又需要提供访问权限的情况下是一个不错的选择。尤其是在乙方在做一些操作的时候,要密码和给密码是一个纠结的问题。不给没法工作,给了又对信息安全又影响。
在oracle和mysql中都有相应的解决方案,大道至简,这个功能的目的都是类似的。
在oracle中可以通过设置wallet来实现,在10g版本开始支持。而在mysql中自5.6版本开始可以使用--login-path来实现。
先来看看oracle中的wallet实现无密码登录,,可以通过mkstore来配置,我们可以使用--help得到命令使用的帮助。
[ora11g@oel1 admin]$ mkstore --help
 oracle secret store tool : version 11.2.0.1.0 - production
 copyright (c) 2004, 2009, oracle and/or its affiliates. all rights reserved.
 no wallet location specified.
 mkstore [-wrl wrl] [-create] [-createsso] [-createlsso] [-createalo] [-delete] [-deletesso] [-list] [-createentry alias secret] [-viewentry alias] [-modifyentry alias secret] [-deleteentry alias] [-createcredential connect_string username password] [-listcredential] [-modifycredential connect_string username password] [-deletecredential connect_string] [-help] [-nologo]
我们首先来创建钱包,指定钱包路径为/u02/ora11g/wallet,对于密码还是有一定的要求,太简单也不行。
$ mkstore -wrl /u02/ora11g/wallet -create
 oracle secret store tool : version 11.2.0.1.0 - production
 copyright (c) 2004, 2009, oracle and/or its affiliates. all rights reserved.
 enter password:         
 enter password again: 
生成钱包后,会在指定的路径下生成两个文件。
$ ll
 total 8
 -rw------- 1 ora11g dba 3589 may 17 21:37 cwallet.sso
 -rw------- 1 ora11g dba 3512 may 17 21:37 ewallet.p12
我们可以指定临时的连接串来配置到钱包里面,比如我们认为test11g是一个临时连接串,可以使用tnsping来测试,确保连接串是可访问的。
$tnsping test11g
 attempting to contact (description = (address_list = (address = (protocol = tcp)(host = oel1.oracle.com)(port = 1511))) (connect_data = (service_name = test11g)))
 ok (0 msec)
配置完成之后,我们需要在登录之前在sqlnet.ora中配置钱包的路径。sqlnet.ora中需要配置的内容如下:
$ cat sqlnet.ora
 wallet_location =
  (source =
    (method = file)
    (method_data =
      (directory = /u02/ora11g/wallet)
    )
  )
sqlnet.wallet_override=true
这些配置都搞定以后我们就可以指定对应的连接串,对应的用户名密码。
$ mkstore -wrl /u02/ora11g/wallet -createcredential test11g n1 n1
 oracle secret store tool : version 11.2.0.1.0 - production
 copyright (c) 2004, 2009, oracle and/or its affiliates. all rights reserved.
 enter wallet password:  l      1
create credential oracle.security.client.connect_string1
配置完成之后工作就完成了,我们可以简单验证一下。
$ sqlplus /@test11g
 sql*plus: release 11.2.0.1.0 production on sun may 17 21:45:59 2015
 with the partitioning, olap, data mining and real application testing options
 >
而如果使用mysql来实现,则需要通过mysql_config_editor来配置。
mysql_config_editor的命令提示如下,可以看出可使用的选项还是相对比较简单的。
[mysql@oel1 ~]$ mysql_config_editor set --help
 mysql_config_editor ver 1.0 distrib 5.6.23, for linux-glibc2.5 on i686
 copyright (c) 2012, 2015, oracle and/or its affiliates. all rights reserved.
 oracle is a registered trademark of oracle corporation and/or its
 affiliates. other names may be trademarks of their respective
 owners.
 mysql configuration utility.
 description: write a login path to the login file.
 usage: mysql_config_editor [program options] [set [command options]]
  -?, --help          display this help and exit.
  -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.
  -w, --warn          warn and ask for confirmation if set command attempts to
                      overwrite an existing login path (enabled by default).
                      (defaults to on; use --skip-warn to disable.)
我们直接可以通过一个命令来完成配置,制定这个无密码登录的别名为fastlogin
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product