37 0 0 0
采用docker安装方式
docker pull mysql:5.7.33
mkdir /home/mysql
docker run -p 3306:3306 --name mysql -v /home/mysql/conf:/etc/mysql -v /home/mysql/logs:/var/log/mysql -v /home/mysql/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.7.33
连接mysql查询是否启动binlog,执行sql:
show variables like '%log_bin%'
log_bin的值:OFF表示关,ON表示开
如果没开按照以下流程开启binlog
cd /home/mysql/conf
[mysqld]
log-bin=/var/log/mysql/mysql-bin
binlog_format=ROW
server-id=123454
如果是新建的必须要加上[mysqld] log-bin的值是生成binlog目录,路径最后面的mysql-bin是生成的文件名,MySQL会自动在文件名后面加后缀,/var/log/mysql这个目录要设置成容器里面的路径,不是宿主机,不是宿主机,不是宿主机 binlog_format有三种不同模式:Mixed,Statement,Row我们用Row详情 server-id集群id随便写
docker restart mysql
chmod -R 764 *
show variables like '%log_bin%'
docker pull canal/canal-server
docker run -d --name canal-server -p 11111:11111 canal/canal-server
mkdir /home/canal/conf
mkdir /home/canal/logs
docker cp canal-server:/home/admin/canal-server/conf /home/canal/
# 数据库连接信息
canal.instance.master.address=127.0.0.1:3306
canal.instance.dbUsername=canal
canal.instance.dbPassword=canal
# 监听表
canal.instance.filter.regex=blog_tag,ppt_tag
# mq的topic
canal.mq.topic=mysql
# tcp, kafka, RocketMQ
canal.serverMode = kafka
canal.zkServers =note01:2181,note02:2181,note03:2181
canal.mq.servers = note01:9092,note02:9092,note03:9092
CREATE USER canal IDENTIFIED BY 'canal';
GRANT SELECT, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'canal'@'%';
FLUSH PRIVILEGES;
docker rm -f canal-server
docker run -d --name canal-server -v /home/canal/conf:/home/admin/canal-server/conf -v /home/canal/logs:/home/admin/canal-server/logs -p 11111:11111 canal/canal-server
删除容器,启动的时候加参数 --privileged=true
CREATE USER 用户名 IDENTIFIED BY '密码';
命令:
GRANT privileges ON databasename.tablename TO 'username'@'host'
示例:
GRANT ALL ON *.* TO 'hk'@'%';
命令:
REVOKE privilege ON databasename.tablename FROM 'username'@'host';
DROP USER 'username'@'host';
SELECT * FROM mysql.user;