请问tidb怎么远程连接啊,我想用另外一台电脑的mysql连接tidb,连接会被拒绝,是需要开启一些权限吗?
TiDB其实和MySQL开启远程访问一样,在TiDB Server机器的黑屏模式下进行类似如下操作,在网络通的情况下就可以远程连接TiDB了
use mysql;
alter user ‘root’@‘%’ identified by ‘password’;
flush privileges;
看下4000端口是否通,账号是否有远程连接权限,具体报什么错发下吧
怎么连的?
另一台电脑上先telnet tidb安装电脑的IP 4000试一下端口通不通。
输入alter user ‘root’@‘%’ identified by ‘password’;时报ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your TiDB version for the right syntax to use line 1 column 23 near "%’ identified by ‘password’"这个错误请问怎么解决
注意中文标点符号,要改成英文的。
另外,这个命令是修改数据库用户root密码的脚本。后面的password要替换为你要设置的登录密码。
如果要修改密码也可以试试这个脚本
update mysql.user set authentication_string=password(‘设置的密码’) where user=‘root’ ;
flush privileges;
你需要创建一个数据库的用户,权限有%(可远程的权限)。
使用管理员权限创建账号
create user ‘ncayusys’@‘%’ IDENTIFIED WITH mysql_native_password BY ‘QhmHJn2gZIE7’;
– 指定数据库
grant select,update,insert on ncayudb.* to ‘ncayusys’@‘%’;
– 所有数据库
grant select,update,insert on . to ‘ncayusys’@‘%’;
flush privileges;
使用MySQL连接tidb
mysql -h 192.168.227.134 -P 4000 -u ncayusys -p
备份数据库ncayudb
/data1/tidbbackup/mysql57/bin/mysqldump -h 192.168.227.134 -P 4000 -u ncayusys -p ncayudb |gzip >/data/tidbbackup/ncayudb.sql.gz
查看用户权限
select user,host from mysql.user;
修改root账号的“localhost”权限为“%”权限
update user set host = “%” where user = “root” and host = “localhost”;
修改root账号的“%”权限为“localhost”权限;root账号只能本地使用
mysql> update user set host = “localhost” where user = “root” and host = “%”;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
更改密码:
ALTER USER ‘root’@‘localhost’ IDENTIFIED WITH mysql_native_password BY ‘Ncayu@bNuPc3’;
刷新一下
flush privileges;
测试账号密码修改后是否可以正常登录
mysql -u root -p Ncayu@bNuPc3
你好,看一下你需要修改哪些内容,然后执行命令即可
此话题已在最后回复的 60 天后被自动关闭。不再允许新回复。