当前位置:网站首页>[Clickhouse column] create a new library, user and role
[Clickhouse column] create a new library, user and role
2022-06-11 16:43:00 【Alphabet brother】
List of articles
One 、 Create a new database
clickhouse The syntax for creating a database is almost the same as other relational databases , The difference is clickhouse Cluster exists cluster And library engine engine The concept of , You can specify as needed . If there is no special need , The default can be .
CREATE DATABASE [IF NOT EXISTS] db_name [ON CLUSTER cluster] [ENGINE = engine(...)]
When creating a database , We first need to confirm the directory where the database files are saved , about clickhouse The user has read and write permission . If you install , The database file directory has not been modified , The default directory is /var/lib/clickhouse/. We can use the following command , Change the owner of this directory and its subdirectories to clickhouse user .
chown clickhouse /var/lib/clickhouse/ -R
After completing the above steps , You can go through clickhouse-client -m --password < Your password > Connect clichouse Service instance , Create database's SQL as follows :
:) CREATE DATABASE acaidb;
After creating the database , Use show databases; Command to see the current clickhouse, What are they? database.(acaidb We built it ourselves ,default and system yes clickhouse Created by default database)
:) show databases;
┌─name────┐
│ acaidb │
│ default │
│ system │
└─────────┘
Two 、 by default Add management authority to the account
ClickHouse Create a database by default default, A user is created by default default. We are now targeting default Users increase access management permission , Because the user does not have administrator permission by default , namely : By default , Cannot add role with this user 、 Add users 、 And other permission management operations .
So in order for default Users have more administrative authority , We modify /etc/clickhouse-server/users.xml file , stay users-> default In the label , take access_management Remove comments from .( In some versions, the default value is 0, It is amended as follows 1)
After modifying the configuration file , restart clickhouse-server, Use the following command :
clickhouse restart
3、 ... and 、 Create roles and users
Create the role
Create a character acaidb_rw, This role is for the database acaidb Read and write permission .
CREATE ROLE acaidb_rw;
GRANT SELECT, INSERT, ALTER UPDATE, ALTER DELETE ON acaidb.* TO acaidb_rw;
If you let a role only allow select, Data modification is not allowed , The following statement can .
CREATE ROLE acaidb_read;
GRANT SELECT ON acaidb.* TO acaidb_read;
Create general accounts and empower
We create accounts separately reader and writer, Then put the read-only role ro Assigned to reader, Assign the read-write role to writer. such ,reader Have read-only permission ,writer Have read and write access . Create a new database user acai, And set the password ( What follows is < Your password > Replace ). And give it to the user acai Assign read and write permission roles acaidb_rw .
CREATE USER IF NOT EXISTS acai IDENTIFIED WITH sha256_password BY '< Your password >';
GRANT acaidb_rw TO acai;
Use the following command to access clickhouse data ,show databases obtain acaidb, It shows that we have succeeded in . because acai Users can only access acaidb.
# clickhouse-client -m -u acai --password '< Your password >' --query 'show databases;'
acaidb
Recommended reading
边栏推荐
- solr(一)solr的安装及权限控制
- Enterprise purchase, sales and inventory management system based on SSM framework [source code + database + design]
- 什么是rs邮票纸?
- Leetcode 1974. Minimum time to type words using a special typewriter (yes, once)
- C starts an external EXE file and passes in parameters
- (验证文件)validateJarFile...报错
- Oracle generates non duplicate string sys_ Guid() and MySQL generate unique values
- WYSIWYG markdown editor: typora
- 2022年高处安装、维护、拆除考试模拟100题及在线模拟考试
- golang中的异常处理和异常使用
猜你喜欢

为什么芯片设计也需要「匠人精神」?

Pycharm使用小技巧 - 如何设置背景图片

Detailed explanation of the functions of list and dict data types

2022熔化焊接与热切割上岗证题目及模拟考试

2022 safety officer-a certificate test question simulation test question bank simulation test platform operation

【clickhouse专栏】新建库、用户及角色

RSP: An Empirical Study of remote sensing pre training
![Enterprise purchase, sales and inventory management system based on SSM framework [source code + database + design]](/img/af/b5b5a69654a28d252cc5954b5e847a.png)
Enterprise purchase, sales and inventory management system based on SSM framework [source code + database + design]

GemBox.Bundle 43.0 Crack

Opencv相机标定之圆形标识点中心检测
随机推荐
2022 R1 quick opening pressure vessel operation test question bank and simulation test
关联关系
leetcode463. 岛屿的周长(简单)
ASP.NET教育OA系统源码 教育行业OA系统源码带文档
7个人生工具:SWOT、PDCA、6W2H、SMART、WBS、时间管理、二八原则
虚拟局域网划分与虚拟局域网间路由(VLAN)
JVM 的组成
Web page design example assignment -- Introduction to Henan cuisine (4 pages) web final assignment design web page_ Dessert and gourmet college students' web design homework finished product
Web security - shooting range notes
What is RS stamp paper?
Difference between select into from and insert into select
leetcode684. Redundant connection (medium)
Search and graph theory: Dijkstra finding the shortest path i-dijkstra (shortest path)
做跨境电商卖什么产品好?热销类目有哪些?
2022熔化焊接与热切割上岗证题目及模拟考试
2022 molten welding and thermal cutting work license and simulation examination
Learn about Prometheus from 0 to 1
Project failed to load the configuration file of Nacos configuration center
2022高压电工特种作业证考试题库及在线模拟考试
2022年危险化学品经营单位主要负责人考试模拟100题及模拟考试