https://tidb.net/blog/6794a34b#%E6%96%B9%E5%BC%8F%E4%B8%80%EF%BC%9A%E5%91%BD%E4%BB%A4%E8%A1%8C%E8%BE%93%E5%85%A5%E6%96%B9%E5%BC%8F

方式一:命令行输入方式

[root@iZuf6d7xln13sovvijl68rZ ~]# mysql -uroot -P4000 -h10.0.0.86

ERROR 1045 (28000): Access denied for user 'root'@'10.0.0.83' (using password: NO)

[root@iZuf6d7xln13sovvijl68rZ ~]# mysql -uroot -P4000 -h10.0.0.86 -p

Enter password:

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

Your MySQL connection id is 691323

Server version: 5.7.25-TiDB-v6.1.0-alpha TiDB Server (Apache License 2.0) Community Edition, MySQL 5.7 compatible

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

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

MySQL [(none)]>

正常方式下需要通过 -p 输入密码的方式连接 TiDB。

方式二:环境变量方式

[root@iZuf6d7xln13sovvijl68rZ ~]# export MYSQL_PWD=passw0RD

[root@iZuf6d7xln13sovvijl68rZ ~]# mysql -uroot -P4000 -h10.0.0.86

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

Your MySQL connection id is 691477

Server version: 5.7.25-TiDB-v6.1.0-alpha TiDB Server (Apache License 2.0) Community Edition, MySQL 5.7 compatible

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

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

MySQL [(none)]>

通过设定 MYSQL_PWD 环境变量方式,可以直接在命令行连接时传入密码,不需要指定 -p 选项。

取消 MYSQL_PWD 环境变量设置的步骤如下:

[root@iZuf6d7xln13sovvijl68rZ ~]# export MYSQL_PWD=

[root@iZuf6d7xln13sovvijl68rZ ~]# mysql -uroot -P4000 -h10.0.0.86

ERROR 1045 (28000): Access denied for user 'root'@'10.0.0.83' (using password: NO)

方式三:配置文件方式

在 /etc/my.cnf 配置下添加 [mysql] 对应的配置

[root@iZuf6d7xln13sovvijl68rZ ~]# head -n2 /etc/my.cnf

[mysql]

password=passw0RD

[root@iZuf6d7xln13sovvijl68rZ ~]# mysql -uroot -P4000 -h10.0.0.86

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

Your MySQL connection id is 691787

Server version: 5.7.25-TiDB-v6.1.0-alpha TiDB Server (Apache License 2.0) Community Edition, MySQL 5.7 compatible

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

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

MySQL [(none)]>

取消设置只需要将 my.cnf 中的配置文件删除即可。

方式四:mysql_config_editor 方式

[root@iZuf6d7xln13sovvijl68rZ ~]# ./mysql_config_editor print --all

[root@iZuf6d7xln13sovvijl68rZ ~]# ./mysql_config_editor set --login-path=test --user=root  --host=10.0.0.83 --port=3000 --password

Enter password:

[root@iZuf6d7xln13sovvijl68rZ ~]# ./mysql_config_editor print --all

[test]

user = root

password = *****

host = 10.0.0.83

port = 3000

[root@iZuf6d7xln13sovvijl68rZ ~]# cat /root/.mylogin.cnf

        ��2"�

�?��│�Ũ�ٹ    De����6ɡ⎽�_ �▒ȍ ;

         ]��┐�

↑ �/F?;d��J

⎻[⎼⎺⎺├@☃Z┤°6d7│┌┼13⎽⎺┴┴☃┘┌68⎼Z ·]#

[root@iZuf6d7xln13sovvijl68rZ ~]# ./mysql --login-path=test

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

Your MySQL connection id is 753

Server version: 5.7.25-TiDB-v6.1.0-alpha TiDB Server (Apache License 2.0) Community Edition, MySQL 5.7 compatible

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

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> \q

取消设置按照如下步骤:

[root@iZuf6d7xln13sovvijl68rZ ~]# ./mysql_config_editor remove --login-path=test

[root@iZuf6d7xln13sovvijl68rZ ~]# ./mysql_config_editor print --all

[root@iZuf6d7xln13sovvijl68rZ ~]#

方式五:Socket 方式连接

Socket 方式只能本地连接

[root@iZuf6d7xln13sovvijl68rZ scripts]# cd /tidb-deploy/tidb-3000/scripts

[root@iZuf6d7xln13sovvijl68rZ scripts]# cat run_tidb.sh

#!/bin/bash

set -e

# WARNING: This file was auto-generated. Do not edit!

#          All your edit might be overwritten!

DEPLOY_DIR=/tidb-deploy/tidb-3000

cd "${DEPLOY_DIR}" || exit 1

exec env GODEBUG=madvdontneed=1 bin/tidb-server \

    -P 3000 \

    --status="10080" \

    --host="0.0.0.0" \

    --advertise-address="10.0.0.83" \

    --store="tikv" \

    --initialize-insecure \

    --path="10.0.1.185:2379,10.0.2.29:2379,10.0.0.88:2379" \

    --log-slow-query="/tidb-deploy/tidb-3000/log/tidb_slow_query.log" \

    --config=conf/tidb.toml \

    --socket="/tidb-deploy/tidb-3000/tidb.sock" \

    --log-file="/tidb-deploy/tidb-3000/log/tidb.log" 2>> "/tidb-deploy/tidb-3000/log/tidb_stderr.log"

[root@iZuf6d7xln13sovvijl68rZ scripts]# tiup cluster restart tidb-prod -N 10.0.0.83:3000

[root@iZuf6d7xln13sovvijl68rZ scripts]# ps -ef | grep tidb-server

root     15153     1  4 17:25 ?        00:00:00 bin/tidb-server -P 3000 --status=10080 --host=0.0.0.0 --advertise-address=10.0.0.83 --store=tikv --initialize-insecure --path=10.0.1.185:2379,10.0.2.29:2379,10.0.0.88:2379 --log-slow-query=/tidb-deploy/tidb-3000/log/tidb_slow_query.log --config=conf/tidb.toml --socket=/tidb-deploy/tidb-3000/tidb.sock --log-file=/tidb-deploy/tidb-3000/log/tidb.log

root     15292 12885  0 17:26 pts/9    00:00:00 grep --color=auto tidb-server

[root@iZuf6d7xln13sovvijl68rZ scripts]# ll /tidb-deploy/tidb-3000/tidb.sock

srwxr-xr-x 1 root root 0 5月   5 17:25 /tidb-deploy/tidb-3000/tidb.sock

[root@iZuf6d7xln13sovvijl68rZ scripts]# mysql -uroot -hlocalhost -S /tidb-deploy/tidb-3000/tidb.sock

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

Your MySQL connection id is 403

Server version: 5.7.25-TiDB-v6.1.0-alpha TiDB Server (Apache License 2.0) Community Edition, MySQL 5.7 compatible

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

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

MySQL [(none)]> show processlist;

+------+------+-----------+------+---------+------+------------+------------------+

| Id   | User | Host      | db   | Command | Time | State      | Info             |

+------+------+-----------+------+---------+------+------------+------------------+

|  403 | root | localhost | NULL | Query   |    0 | autocommit | show processlist |

+------+------+-----------+------+---------+------+------------+------------------+

1 row in set (0.00 sec)

[转帖]命令行非明文密码连接 TiDB的更多相关文章

  1. 可以在命令行直接使用密码来进行远程连接和远程拉取文件的命令:sshpass

      应用范围:可以在命令行直接使用密码来进行远程连接和远程拉取文件. 使用前提:对于未连接过的主机.而又不输入yes进行确认,需要进行sshd服务的优化: # vim /etc/ssh/ssh_con ...

  2. Windows命令行中使用SSH连接Linux

    转自 http://www.linuxidc.com/Linux/2014-02/96625.htm 1.下载: openssh for Winodws: 免费下载地址在 http://linux.l ...

  3. 树莓派Raspberry命令行配置无线网络连接

    前言: 树莓派有多种联网的方式,通过有线网或者通过无线网.通过有线网连接是比较简单的,在开启dhcp的路由器下,直接插上网线就可以联网,本文介绍树莓派无线联网的方式.再没联网的情况下,如果没有屏幕等外 ...

  4. Python 命令行非阻塞输入

    很久很久以前,系windows平台下,用C语言写过一款贪食蛇游戏,cmd界面,用kbhit()函数实现非阻塞输入.系windows平台下用python依然可以调用msvcrt.khbit实现非阻塞监听 ...

  5. windows防火墙实验-命令行设置远程桌面连接以及禁止浏览器上网

    windows防火墙实验-设置远程桌面连接以及禁止浏览器上网 实验环境: 1.win2008远程桌面服务 2.win7-1 10.10.10.136 3.win7-2 10.10.10.153 实验步 ...

  6. Windows命令行更改有线本地连接IP地址及DNS的bat脚本

    有些场景需要测试网络通不通等,每次打开网络和共享中心真烦,win10右下角还进不去了,shit! 运行ncpa.cpl也打开那个界面也是费劲吧啦,索性写个bat吧!为啥要写?还不是因为懒!可以把脚本复 ...

  7. 用户登录密码RSA加密后传输的实现,非明文密码传输

    在用户登录页面,用户输入密码后,在传送到服务器端时,为防止在密码传送过程中,被如360这种东东给拦截到, 需要在传送前对密码进行加密,然后再传送! 利用RSA加密,在客户端使用公钥对密码进行加密,在服 ...

  8. xampp 命令行修改数据库密码

    进入xampp 下 ./mysql -u root -p password 进入mysql控制台 UPDATE mysql.user SET Password=PASSWORD('password') ...

  9. 命令行修改mysql密码和远程访问

    http://jingyan.baidu.com/article/a3a3f8118cea488da2eb8a0a.html

  10. sshpass-Linux命令之非交互SSH密码验证

    sshpass-Linux命令之非交互SSH密码验证 参考网址:https://www.cnblogs.com/chenlaichao/p/7727554.html ssh登陆不能在命令行中指定密码. ...

随机推荐

  1. ubuntu upgrade problem

    出现问题: W: Failed to fetch bzip2:/var/lib/apt/lists/partial/ppa.launchpad.net_webupd8team_java_ubuntu_ ...

  2. JavaFx FXML入门(五)

    JavaFx FXML入门(五) JavaFX 从入门入门到入土系列 JavaFx的FXML类似安卓中的视图文件,可以添加样式,添加css,添加id然后在java代码中绑定点击事件.可以使用工具编辑: ...

  3. CodeForces 1082E Increasing Frequency 计数 递推 思维

    原题链接 题意 给我们一个长为n的序列A以及一个整数c,对这个序列的任何一个连续区间[l, r],我们可以给这个区间内的数统一加上一个我们任取的整数k. 要求我们只能做上述操作一次,问最终序列内最多有 ...

  4. Kubernetes的拐点助推器:左手开源,右手边缘计算

    摘要:KubeEdge 是首个基于 Kubernetes 扩展的,提供云边协同能力的开放式智能边缘计算平台,也是 CNCF 在智能边缘领域的首个正式项目.依托 Kubernetes 强大的容器编排和调 ...

  5. PPT 动画-制作一个倒酒

    波浪往左上方,慢慢运动 数字 渐入 + 渐出 + 居中对齐 酒杯绘制 波浪绘制 上方的点全部设成[平滑顶点] https://getwaves.io/ 快速生成波浪[Office 2016 不支持插入 ...

  6. 【Java爬虫】如何通过 API 递归分页爬取网页数据

    前言 在最近的互联网项目开发中,需要获取用户的访问ip信息进行统计的需求,用户的访问方式可能会从微信内置浏览器.Windows浏览器等方式对产品进行访问. 当然,获取这些关于ip的信息是合法的.但是, ...

  7. 阿里云的“终端云化”实践,基于ENS进行边缘架构构建

    终端无休止的更新迭代,是软件对计算资源的需求激增. 作者|王广芳 编辑|IMMENSE 终端云化:打破硬件的桎梏 近几年,"终端云化"技术开始规模化落地,其核心思想是"计 ...

  8. 【每日一题】16.Treepath (LCA + DP)

    补题链接:Here 题意总结:寻找有多少条两个点之间偶数路径 看完题,很容易想到在树型中,同一层的节点必然是偶数路径到达,还有就是每隔两层的节点一样可以到达,所以我就理所应当的写了如下代码 using ...

  9. L2-016 愿天下有情人都是失散多年的兄妹 (25分) (简单递归判断)

    L2-016 愿天下有情人都是失散多年的兄妹 (25分) 呵呵.大家都知道五服以内不得通婚,即两个人最近的共同祖先如果在五代以内(即本人.父母.祖父母.曾祖父母.高祖父母)则不可通婚.本题就请你帮助一 ...

  10. 秒杀活动java怎么实现

    秒杀与其他业务最大的区别在于:秒杀的瞬间: (1)系统的并发量会非常的大 (2)并发量大的同时,网络的流量也会瞬间变大. 一个秒杀或者抢购页面,通常分为2个部分,一个是静态的HTML等内容,另一个就是 ...