oracle和mysql登录方式_关于Oracle和MySQL中的无密码登录

[email protected] 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

配置完成之后工作就完成了,我们可以简单验证一下。

$ [email protected]>

而如果使用MySQL来实现,则需要通过mysql_config_editor来配置。

mysql_config_editor的命令提示如下,可以看出可使用的选项还是相对比较简单的。

[[email protected] ~]$ 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

[[email protected] ~]$ mysql_config_editor set --login-path=fastlogin --user=root --host=localhost --password --socket=/u02/mysql/mysqld_mst.sock

Enter password:

配置完成之后,会在当前路径下生成一个隐藏文件.mylogin.cnf

[[email protected] ~]$ ll -la .mylogin*

-rw------- 1 mysql dba 480 May 17 22:10 .mylogin.cnf

[[email protected] ~]$

大功告成,这个时候直接登录即可。

[[email protected] ~]$mysql --login-path=fastlogin

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 3

Server version: 5.6.23-enterprise-commercial-advanced-log MySQL Enterprise Server - Advanced Edition (Commercial)

Copyright (c) 2000, 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.

Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.

mysql>

原文:http://blog.itpub.net/23718752/viewspace-1659551/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值