【TiDB】09-修改tidb客户端访问密码

目录

1、修改配置文件

2、停止tidb-server

3、以root方式启动脚本

4、修改密码

5、停止脚本重启服务


1、修改配置文件

进入tidb-server默认部署位置

复制代码
#切换tidb账号
su tidb

# 进入tidb-server部署路径
cd /tidb-deploy/tidb-4000

# 修改配置
vim ./conf/tidb.toml

添加内容

security

skip-grant-table = true

2、停止tidb-server

复制代码
#
tiup cluster display tidb-test

# 只停止 tidb-server 服务
tiup cluster stop tidb-test -R tidb

3、以root方式启动脚本

修改完配置后,不能以 tiup cluster 命令方式启动,否则会出现启动失败

1)异常如下

Error: failed to start tidb: failed to start: 192.168.20.113 tidb-4000.service, please check the instance's log(/tidb-deploy/tidb-4000/log) for more detail.: timed out waiting for port 4000 to be started after 2m0s

"code": 1, "error": "failed to start tidb: failed to start: 192.168.20.113 tidb-4000.service, please check the instance's log(/tidb-deploy/tidb-4000/log) for more detail.: timed out waiting for port 4000 to be started after 2m0s", "errorVerbose": "timed out waiting for port 4000 to be started after 2m0s\ngithub.com/pingcap/tiup/pkg/cluster/module.(*WaitFor).Execute\n\tgithub.com/pingcap/tiup/pkg/cluster/module/wait_for.go:92\ngithub.com/pingcap/tiup/pkg/cluster/spec.PortStarted\n\tgithub.com/pingcap/tiup/pkg/cluster/spec/instance.go:129\ngithub.com/pingcap/tiup/pkg/cluster/spec.(*BaseInstance).Ready\n\tgithub.com/pingcap/tiup/pkg/cluster/spec/instance.go:167\ngithub.com/pingcap/tiup/pkg/cluster/operation.startInstance\n\tgithub.com/pingcap/tiup/pkg/cluster/operation/action.go:405\ngithub.com/pingcap/tiup/pkg/cluster/operation.StartComponent.func1\n\tgithub.com/pingcap/tiup/pkg/cluster/operation/action.go:535\ngolang.org/x/sync/errgroup.(*Group).Go.func1\n\tgolang.org/x/[email protected]/errgroup/errgroup.go:75\nruntime.goexit\n\truntime/asm_amd64.s:1650\nfailed to start: 192.168.20.113 tidb-4000.service, please check the instance's log(/tidb-deploy/tidb-4000/log) for more detail.\nfailed to start tidb"}

2)如果出现异常退出后,再次执行出现如下错误

terror.go:309\] \["unexpected error"\] \[error="fslock: lock is held"\] \[stack="github.com/pingcap/tidb/pkg/parser/terror.MustNil\\n\\t/workspace/source/tidb/pkg/parser/terror/terror.go:309\\nmain.main\\n\\t/workspace/source/tidb/cmd/tidb-server/main.go:288\\nruntime.main\\n\\t/usr/local/go/src/runtime/proc.go:267"\] \[stack="github.com/pingcap/tidb/pkg/parser/terror.MustNil\\n\\t/workspace/source/tidb/pkg/parser/terror/terror.go:309\\nmain.main\\n\\t/workspace/source/tidb/cmd/tidb-server/main.go:288\\nruntime.main\\n\\t/usr/local/go/src/runtime/proc.go:267"

通过查找进程的方式,kill的对应程序,然后重启

复制代码
ps -ef|grep run_tidb

kill -9 181877

sudo sh run_tidb.sh

正确处理方式

复制代码
su tidb

cd /tidb-deploy/tidb-4000/scripts

# 必须以root方式启动
sudo sh run_tidb.sh

启动完后,保持窗口不要关闭,开启新的窗口进行后续操作。

4、修改密码

可以使用命令行的方式访问数据库

复制代码
mysql -h 127.0.0.1 -P 4000 -u root

或者借助Navicat工具访问

注意需要切换到mysql 实例

然后可以通过 SET PASSWORD FOR 或者 ALTER USER 语句完成:

复制代码
SET PASSWORD FOR 'root'@'%' = 'mypass';

或者执行

复制代码
ALTER USER 'root'@'%' IDENTIFIED BY 'mypass';

5、停止脚本重启服务

1)将1中的tidb.toml 配置添加的内容移除

2)停止3中的run_tidb.sh脚本

3)重启tidb-server

复制代码
tiup cluster start tidb-test -R tidb

最后检查服务是否运行正常

参考文章:

TiDB 用户账户管理 | PingCAP 文档中心

相关推荐
赵渝强老师2 天前
【赵渝强老师】TiDB SQL层的工作机制
数据库·sql·tidb
观测云10 天前
TiDB 可观测性最佳实践
tidb
赵渝强老师13 天前
【赵渝强老师】使用TiDB的审计日志
数据库·tidb
可观测性用观测云15 天前
TiDB 可观测性最佳实践
tidb
Sirius Wu15 天前
TiDB 深度解析与 K8S 实战指南
容器·kubernetes·tidb
PingCAP16 天前
PingCAP“一号员工”唐刘:回顾我与 TiDB 的十年成长之旅
数据库·tidb
转转技术团队17 天前
告别人工搬运!TiDB/MySQL双库同步工具如何为业务提效100%?
mysql·tidb·测试
MiniFlyZt22 天前
分布式数据库TiDB:架构、核心特性与生产实践(分库分表)
java·数据库·分布式·spring cloud·微服务·tidb
PingCAP23 天前
从单一到多活,麦当劳中国的数据库架构迁移实战
数据库·tidb
XMYX-01 个月前
TiDB 部署指南(单机模式)& CentOS 7 安装 MariaDB 教程
centos·tidb·mariadb