目录
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/sync@v0.1.0/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_tidbkill -9 181877sudo sh run_tidb.sh
正确处理方式
su tidbcd /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 文档中心