建库和用户需要使用root进行连接。

[admin@ensbrain observer01]$ mysql -h127.1 -uroot@mysql01#obcluster -P2883 -p'密码' -c -A
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 139881
Server version: 5.6.25 OceanBase 3.1.1 (r20210508100750-b47c8fdd84ca9281ec7cb0122ad8962aaa55e21a) (Built May  8 2021 10:37:40)

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)]> show databases;
+--------------------+
| Database           |
+--------------------+
| oceanbase          |
| information_schema |
| mysql              |
| test               |
| yewu               |
| aespess            |
| aespnative         |
+--------------------+
7 rows in set (0.007 sec)
MySQL [(none)]> select user,host from mysql.user;
+------------+------+
| user       | host |
+------------+------+
| root       | %    |
| ORAAUDITOR | %    |
| qyq        | %    |
| aespess    | %    |
+------------+------+
4 rows in set (0.018 sec)

MySQL [(none)]> create database log_collect;           //创建数据库
Query OK, 1 row affected (0.026 sec)

MySQL [(none)]> create user collect@'%' identified by '密码';    //创建用户
Query OK, 0 rows affected (0.021 sec)

MySQL [(none)]> grant all privileges on log_collect.* to collect@'%';    //授权
Query OK, 0 rows affected (0.015 sec)

MySQL [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| oceanbase          |
| information_schema |
| mysql              |
| test               |
| yewu               |
| aespess            |
| aespnative         |
| log_collect        |
+--------------------+
8 rows in set (0.006 sec)

MySQL [(none)]> 
MySQL [(none)]> select user,host from mysql.user;
+------------+------+
| user       | host |
+------------+------+
| root       | %    |
| ORAAUDITOR | %    |
| qyq        | %    |
| aespess    | %    |
| collect    | %    |
+------------+------+
5 rows in set (0.007 sec)


mysql -h127.1 -ucollect@mysql01#obcluster -P2883 -p'密码' -c -A log_collect

Logo

DAMO开发者矩阵,由阿里巴巴达摩院和中国互联网协会联合发起,致力于探讨最前沿的技术趋势与应用成果,搭建高质量的交流与分享平台,推动技术创新与产业应用链接,围绕“人工智能与新型计算”构建开放共享的开发者生态。

更多推荐