Skip to content

Instantly share code, notes, and snippets.

@Slach
Created April 26, 2021 04:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Slach/f87f5e80c4d233de91cec5708bc831e6 to your computer and use it in GitHub Desktop.
Save Slach/f87f5e80c4d233de91cec5708bc831e6 to your computer and use it in GitHub Desktop.
create MySQL8 working dictionary sample
version: "3"
services:
mysql8:
image: mysql:${MYSQL_VERSION:-latest}
environment:
- MYSQL_ALLOW_EMPTY_PASSWORD=1
volumes:
- ./mysql8_table.sql:/docker-entrypoint-initdb.d/mysql8_table.sql
- ./mysql8_log_queries.conf:/etc/mysql/conf.d/mysql8_log_queries.conf
clickhouse:
image: yandex/clickhouse-server:${CLICKHOUSE_VERSION:-latest}
volumes:
- ./mysql8_dictionary.sql:/docker-entrypoint-initdb.d/mysql8_dictionary.sql
DROP DICTIONARY IF EXISTS default.mysql_dictionary;
CREATE DICTIONARY default.mysql_dictionary(
id UInt64,
value String
)
PRIMARY KEY id
LIFETIME(60)
LAYOUT(HASHED())
SOURCE(MYSQL(
host 'mysql8'
port 3306
user 'clickhouse'
password 'clickhouse'
db 'test'
table 'test_table'
));
[mysqld]
information_schema_stats_expiry=0
general_log=1
general_log_file=/var/lib/mysql/all_queries.log
CREATE USER IF NOT EXISTS 'clickhouse'@'%' IDENTIFIED WITH mysql_native_password BY 'clickhouse';
CREATE DATABASE IF NOT EXISTS test;
GRANT ALL PRIVILEGES ON test.* TO 'clickhouse'@'%';
CREATE TABLE IF NOT EXISTS test.test_table (id BIGINT UNSIGNED NOT NULL PRIMARY KEY, value VARCHAR(255));
INSERT INTO test.test_table VALUES(1,'test1'),(2,'test2');
SET GLOBAL information_schema_stats_expiry=0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment