当前位置:网站首页>[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
边栏推荐
- Switching power supply circuit diagram and principle 12V analysis - detailed version
- Leetcode 450. 删除二叉搜索树中的节点
- select into from 和 insert into select 区别
- 2022年R1快开门式压力容器操作考试题库及模拟考试
- R1 Quick Open Pressure Vessel Operation test Library and Simulation Test in 2022
- Zhenxiang, Huawei gives n+1 for voluntary resignation
- [opencvsharp] spot detection barcode decoding image operation image rotation / flip / Zoom perspective transformation image display control demo notes
- 从0到1了解Prometheus
- Composition of JVM
- 2022安全员-C证特种作业证考试题库及答案
猜你喜欢

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

485 days, 21 experiences of my remote office sharing | community essay solicitation

Analysis report on sales status and supply and demand prospects of phosphoric acid fuel cell industry in the world and China 2022-2028 Edition

Time series prediction | MATLAB realizes future multi-step prediction of RBF RBF neural network time series

Jinte Net Foundation will participate in the global strategy conference of dimension chain through online live broadcast

每周推荐短视频:菜鸟CEO谈未来物流新赛道

2022G1工业锅炉司炉考题及模拟考试

2022 high altitude installation, maintenance and demolition test simulation 100 questions and online simulation test

tornado环境搭建及基本框架搭建——熟悉的hello world

RSP: An Empirical Study of remote sensing pre training
随机推荐
从0到1了解Prometheus
核密度估计(二维、三维)
虚拟局域网划分与虚拟局域网间路由(VLAN)
关联关系
R1 Quick Open Pressure Vessel Operation test Library and Simulation Test in 2022
[opencvsharp] spot detection barcode decoding image operation image rotation / flip / Zoom perspective transformation image display control demo notes
A team of heavyweights came to the "digital transformation" arena of CLP Jinxin ice and snow sports
2022 high altitude installation, maintenance and demolition test simulation 100 questions and online simulation test
2022 high voltage electrician special operation certificate examination question bank and online simulation examination
微信小程序时间戳转化时间格式+时间相减
Oracle生成不重复字符串 sys_guid()与Mysql生成唯一值
485天,我远程办公的 21 条心得分享|社区征文
Development planning of China's stainless steel market and suggestions on the development direction of the 14th five year plan 2022-2028
【pytest学习】pytest 用例执行失败后其他不再执行
How unittest knows the execution time of each test case
2022安全员-C证特种作业证考试题库及答案
Analysis of time complexity and space complexity
Composition of JVM
WYSIWYG markdown editor: typora
一套ThinkPHP微信小程序商城源码带后台管理