随笔分类 -  Database

摘要:log_timestamps 设置日志的时间戳,默认UTC,修改为system,必须写入配置文件 log_timestamps=system 阅读全文
posted @ 2021-01-05 10:59 ascertain 阅读(85) 评论(0) 推荐(0)
摘要:log_bin设定binlog的文件名前缀和路径,设置off并不能关闭binlog max_binlog_size设定binlog的最大容量 max_binlog_size=100K max_binlog_size=100M max_binlog_size=1G 查看当前的二进制文件及其positi 阅读全文
posted @ 2021-01-04 18:52 ascertain 阅读(248) 评论(0) 推荐(0)
摘要:mysqlbinlog是二进制日志查看工具,其也会读取/etc/my.cnf中 [client] 段的配置,但是不识别编码 解决方法: 将[client]中 default_character_set=utf8mb4注释 加入 --no-defaults参数 mysqlbinlog --no-def 阅读全文
posted @ 2021-01-04 16:57 ascertain 阅读(1159) 评论(0) 推荐(0)
摘要:#!/bin/env bash # create user xtrabackup@127.0.0.1 identified by 'cruces'; # grant backup_admin,process,reload,lock tables,replication client,replicat 阅读全文
posted @ 2020-12-30 15:40 ascertain 阅读(475) 评论(0) 推荐(0)
摘要:创建表记录event执行过程 CREATE TABLE `mysql`.`event_history` ( `dbname` VARCHAR(128) NOT NULL DEFAULT '', `eventname` VARCHAR(128) NOT NULL DEFAULT '', `startt 阅读全文
posted @ 2020-12-29 14:17 ascertain 阅读(78) 评论(0) 推荐(0)
摘要:select @@sql_mode; 去掉no_zero_in_date & no_zero_date 修改默认值 create_time datetime not null default '0000-01-01 00:00:00' 阅读全文
posted @ 2020-12-29 14:02 ascertain 阅读(387) 评论(0) 推荐(0)
摘要:MySQL中触发器为定义在表上的对象,当触发器所在表出现指定事件,执行相应触发器 Syntax create definer=`root`@`%` trigger `trigger_name` before|alter insert|update|delete on `table_name` for 阅读全文
posted @ 2020-12-29 13:54 ascertain 阅读(256) 评论(0) 推荐(0)
摘要:Server层,选项持久化 mysql> show variables like '%max_connections%'; + + + | Variable_name | Value | + + + | max_connections | 512 | | mysqlx_max_connections 阅读全文
posted @ 2020-12-23 16:35 ascertain 阅读(502) 评论(0) 推荐(0)
摘要:now() sysdate()均为获取当前时间, now()取执行sql时的时间,sysdate()取执行sysdate()函数时的时间 cast(column as type) 类型转换,convert(column,type) type类型 char[n] date 日期 datetime 日期 阅读全文
posted @ 2020-12-23 16:34 ascertain 阅读(101) 评论(0) 推荐(0)
摘要:取消外键约束 set @@foreign_key_check=0 describe information_schema.key_column_usage; 查看表上的索引和foreign key select * from information_schema.key_column_usage w 阅读全文
posted @ 2020-12-22 11:45 ascertain 阅读(605) 评论(0) 推荐(0)
摘要:MySQL开启bin-log后,调用存储过程或者函数以及触发器时,会出现错误号为1418的错误: ERROR 1418 (HY000): This function has none of DETERMINISTIC, NO SQL,or READS SQL DATA in its declarat 阅读全文
posted @ 2020-12-21 10:30 ascertain 阅读(268) 评论(0) 推荐(0)
摘要:结合占位符 drop PROCEDURE if EXISTS test12; -- 使用drop 来删除存储过程或者表 create PROCEDURE test12() -- 创建存储过程 命名为test12 BEGIN set @tableNames = CONCAT('background') 阅读全文
posted @ 2020-12-18 21:26 ascertain 阅读(141) 评论(0) 推荐(0)
摘要:#!/bin/bash host=192.168.100.13 user=root password=password declare -a database database=(CJML_QxbEPC CJML_VIN Grab) function bacula() { #echo $1 mysq 阅读全文
posted @ 2020-12-17 16:00 ascertain 阅读(580) 评论(0) 推荐(0)
摘要:MySQL8,新增data dictionary,数据初始化的时候在Linux下默认使用lower_case_table_names=0的参数,数据库启动的时候,读取/etc/my.cnf中的值,如果/etc/my.cnf中的值与数据库初始化时的值不一样,则会报如下错误 [ERROR] [MY-01 阅读全文
posted @ 2020-12-14 20:17 ascertain 阅读(8659) 评论(0) 推荐(0)
摘要:权限 描述 ALL PRIVILEGES 影响除WITH GRANT OPTION之外的所有权限 ALTER 影响ALTER TABLE命令的使用 ALTER ROUTINE 影响创建存储例程的能力 CREATE 影响CREATE TABLE命令的使用 CREATE ROUTINE 影响更改和弃用存 阅读全文
posted @ 2020-12-14 18:00 ascertain 阅读(143) 评论(0) 推荐(0)
摘要:关闭二进制日志并导入sql mysql -e 'set session sql_log_bin=0;\. ~/b.sql' \. 不能替换成source 阅读全文
posted @ 2020-12-06 23:22 ascertain 阅读(81) 评论(0) 推荐(0)
摘要:路径和密码等相关变量根据实际情况修改,经过验证,数据量不大可用 全量脚本 #!/bin/env bash full_dir=/opt incremental_dir=/opt log_file=/opt/full_backup.log commence=$(date +%s) mysqldump - 阅读全文
posted @ 2020-12-06 01:52 ascertain 阅读(214) 评论(0) 推荐(0)
摘要:数据目录文件解释 -rw-r . 1 mysql mysql 56 11月 16 16:56 auto.cnf -rw-r . 1 mysql mysql 0 11月 16 17:00 binlog.index -rw . 1 mysql mysql 1680 11月 16 16:56 ca-key 阅读全文
posted @ 2020-12-05 21:19 ascertain 阅读(864) 评论(0) 推荐(0)
摘要:数据字典(Data Dictionary)中存储了诸多数据库的元数据信息如图1所示,包括基本Database, table, index, column, function, trigger, procedure,privilege等;以及与存储引擎相关的元数据,如InnoDB的tablespace 阅读全文
posted @ 2020-12-05 21:13 ascertain 阅读(1351) 评论(0) 推荐(1)
摘要:https://github.com/datacharmer/test_db 阅读全文
posted @ 2020-11-30 18:07 ascertain 阅读(661) 评论(0) 推荐(0)