签到成功

知道了

CNDBA社区CNDBA社区

TDSQL集群 数据库 命令行 创建用户失败 说明

2021-07-30 22:16 1807 1 原创 TDSQL
作者: dave

在TDSQL 集群中创建用户报错:http://www.cndba.cn/dave/article/4635http://www.cndba.cn/dave/article/4635http://www.cndba.cn/dave/article/4635

[dave@www.cndba.cn  percona-5.7.17]# mysql -htdsql1 -udave -pdave -P4002
Welcome to the MariaDB monitor.  Commands end with ; or /g.
Your MySQL connection id is 203759
Server version: 5.7.17-11-V2.0R540D002-20191226-1152-log Source distribution

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)]> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MySQL [mysql]>



MySQL [mysql]> grant replication slave on *.* to slave@'%' identified by 'slave';
ERROR 1045 (28000): Access denied for user 'dave'@'%' (using password: YES)

MySQL [mysql]> create user slave identified by 'slave';
Query OK, 0 rows affected (0.07 sec)

MySQL [mysql]> GRANT REPLICATION SLAVE ON *.* TO 'slave'@'%';
ERROR 1045 (28000): Access denied for user 'dave'@'%' (using password: YES)

MySQL [mysql]> drop user slave;
Query OK, 0 rows affected (0.09 sec)

MySQL [mysql]> select host,user from user;
+-----------+--------------+
| host      | user         |
+-----------+--------------+
| %         | CHITUDMSUSER |
| %         | dave         |
| localhost | mysql.sys    |
+-----------+--------------+
3 rows in set (0.00 sec)


MySQL [mysql]> show grants for 'mysql.sys'@'localhost';
+---------------------------------------------------------------+
| Grants for mysql.sys@localhost                                |
+---------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'mysql.sys'@'localhost'                 |
| GRANT TRIGGER ON `sys`.* TO 'mysql.sys'@'localhost'           |
| GRANT SELECT ON `sys`.`sys_config` TO 'mysql.sys'@'localhost' |
+---------------------------------------------------------------+
3 rows in set (0.00 sec)

MySQL [mysql]> show grants for 'dave'@'%';
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Grants for dave@%                                                                                                                                                                                                                                                                      |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, REFERENCES, INDEX, ALTER, SHOW DATABASES, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EVENT, TRIGGER ON *.* TO 'dave'@'%' |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

MySQL [mysql]>

一查看,原来是权限不足,首先在TDSQL 数据库中没有root用户,第二创建的用户没有WITH GRANT OPTION, 所以我们grant 命令执行失败了。 http://www.cndba.cn/dave/article/4635

http://www.cndba.cn/dave/article/4635

但是可以在赤兔平台里创建好用户并赋权:

http://www.cndba.cn/dave/article/4635
http://www.cndba.cn/dave/article/4635

[dave@www.cndba.cn  percona-5.7.17]# mysql -htdsql1 -udave -pdave -P4002
Welcome to the MariaDB monitor.  Commands end with ; or /g.
Your MySQL connection id is 203759
Server version: 5.7.17-11-V2.0R540D002-20191226-1152-log Source distribution

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)]> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MySQL [mysql]>

MySQL [mysql]> show grants for 'slave'@'%';
+-----------------------------------------------+
| Grants for slave@%                            |
+-----------------------------------------------+
| GRANT REPLICATION SLAVE ON *.* TO 'slave'@'%' |
+-----------------------------------------------+
1 row in set (0.04 sec)

MySQL [mysql]>

所以这里应该是TDSQL 在用户权限方面的一个管理措施,就是让用户创建和赋权都在赤兔平台里进行,命令行无法进行权限的修改。 http://www.cndba.cn/dave/article/4635

http://www.cndba.cn/dave/article/4635
http://www.cndba.cn/dave/article/4635

版权声明:本文为博主原创文章,未经博主允许不得转载。

用户评论
* 以下用户言论只代表其个人观点,不代表CNDBA社区的观点或立场
dave

dave

关注

人的一生应该是这样度过的:当他回首往事的时候,他不会因为虚度年华而悔恨,也不会因为碌碌无为而羞耻;这样,在临死的时候,他就能够说:“我的整个生命和全部精力,都已经献给世界上最壮丽的事业....."

  • 2261
    原创
  • 3
    翻译
  • 578
    转载
  • 191
    评论
  • 访问:7970410次
  • 积分:4346
  • 等级:核心会员
  • 排名:第1名
精华文章
    最新问题
    查看更多+
    热门文章
      热门用户
      推荐用户
        Copyright © 2016 All Rights Reserved. Powered by CNDBA · 皖ICP备2022006297号-1·

        QQ交流群

        注册联系QQ