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. DataX快速入门

    DataX3.0快速入门 一.DataX3.0概览 DataX是阿里云DataWorks数据集成的开源版本,在阿里巴巴集团内部被广泛使用的离线数据同步工具/平台.解决了数据库之中的数据同步.迁移问题, ...

  2. BM25(Best Matching 25)算法基本思想

      BM25(Best Matching 25)是一种用于信息检索(Information Retrieval)和文本挖掘的算法,它被广泛应用于搜索引擎和相关领域.BM25 基于 TF-IDF(Ter ...

  3. 带你认识数仓的监控系统TopSQL

    本文分享自华为云社区<GaussDB(DWS)TopSQL总结>,作者:nullptr_ . TopSQL 背景 TopSQL为DWS的监控系统,记录DWS中各个作业.算子级别的资源使用数 ...

  4. 掌数科技携手华为云GaussDB,助力金融科技创新,联合打造行业标杆

    本文分享自华为云社区<掌数科技携手华为云GaussDB,助力金融科技创新,联合打造行业标杆>,作者:GaussDB 数据库 . 近日,在华为开发者大会2023(Cloud)的"G ...

  5. 云小课|使用SQL加密函数实现数据列的加解密

    摘要:数据加密作为有效防止未授权访问和防护数据泄露的技术,在各种信息系统中广泛使用.作为信息系统的核心,GaussDB(DWS)数仓也提供数据加密功能,包括透明加密和使用SQL函数加密. 本文分享自华 ...

  6. ModelArts的雪中送炭,让我拿下CCF BDCI华为Severless工作负载预测亚军

    摘要: 中国计算机学会大数据与计算智能大赛(CCF BDCI)华为Severless工作负载预测亚军方案和ModelArts使用体验分享 本文分享自华为云社区<免费薅ModelArts算力资源- ...

  7. 数据飞轮拆解车企数据驱动三板斧:数据分析、市场画像、A/B 实验

    更多技术交流.求职机会,欢迎关注字节跳动数据平台微信公众号,回复[1]进入官方交流群 近日,火山引擎数智平台(VeDI)2023 数据飞轮汽车行业研讨会在上海举办,活动聚焦汽车行业数字化转型痛点,从字 ...

  8. Python 异步编程原理篇之新旧协程实现对比

    协程的发展流程 再来回顾一下协程的发展流程: python2.5 为生成器引用.send()..throw()..close()方法 python3.3 为引入yield from,可以接收返回值,可 ...

  9. ChatGpt windows+mac os+linux三平台桌面版下载

    1 前言 ChatGPT这段时间还是挺火的,有不了解的小伙伴可以看看这篇ChatGPT为何打响AI新时代的礼炮,一路火花带闪电[1],能简单的了解: 什么是ChatGPT ChatGPT为什么这么火 ...

  10. java中类的普通初始化块一定在静态初始化块后运行吗

    大部分教程都会告诉我们静态初始化块和静态字段总是在初始化块和普通类字段前运行,事实上也确实如此,直到我看到下面这样的代码: public class Test { static Test test = ...