南大通用GBase 8a客户端gccli登录报错Can't find any matching row in the user table

Can't find any matching row in the user table报错截图

GBase 8a数据库的命令行客户端gccli,可以通过-u参数指定数据库用户,如果没有指定,则默认使用:操作系统ssh登录时的操作系统用户名。如果该用户不存在,则报Can't find any matching row in the user table的错误。

其它错误信息,请参考

目录导航

现象

一个报错截图。

Can't find any matching row in the user table报错信息
Can't find any matching row in the user table

如下是复现的用例。

[root@rh6-1 ~]# ssh test@10.0.2.201
test@10.0.2.201's password:
[test@rh6-1 ~]$ su - gbase
Password:
[gbase@rh6-1 ~]$ gccli
ERROR 1133 (42000): Can't find any matching row in the user table

原因

gccli执行时,使用了ssh时的操作系统test用户作为数据库用户。

如果该操作系统用户名,正好在数据库里有相同的数据库用户名,则可以直接使用,比如root,或者gbase.

[root@rh6-1 ~]# ssh gbase@127.0.0.1
gbase@127.0.0.1's password:
Last login: Fri Jan  8 16:48:03 2021 from 10.0.2.201
[gbase@rh6-1 ~]$ gccli
ERROR 1045 (28000): Access denied for user 'gbase'@'localhost' (using password: NO)
[gbase@rh6-1 ~]$ gccli -p
Enter password:

GBase client 8.6.2.43-R28 .125499. Copyright (c) 2004-2021, GBase.  All Rights Reserved.

gbase>

但如果该用户不存在,则报错:Can't find any matching row in the user table。

请注意区分该错误,与指定了-u参数但用户不存在的错误信息区别。

[gbase@rh6-1 ~]$ gccli -uabc
ERROR 1045 (28000): Access denied for user 'abc'@'localhost' (using password: NO)

解决方案

指定-u参数,输入数据库用户名,而不依赖默认值。

[gbase@rh6-1 ~]$ gccli -ugbase -p
Enter password:

GBase client 8.6.2.43-R28 .125499. Copyright (c) 2004-2021, GBase.  All Rights Reserved.

gbase>