分类目录归档:MySQL
mysql 表分区的不同是否会影响正常使用?
MySQL导入远程数据库
mysqldump -h 123.3.3.3 --compress --single-transaction --quick -u OOOK -pPP01 OOOK | mysql -h 127.0.0.3 -u OOOK -pPP01 OOOK
127.0.0.3 适用于连接 OOOK@%
--quick 用于省内存
--compress 用于压缩传输
--single-transaction 防止锁库
[42000][1071] Specified key was too long; max key length is 767 bytes
已email字段为例,改成latin1_bin :
alter table resume
modify email varchar(255) collate latin1_bin not null comment ’email’;
或者取左边一部分来做索引
CREATE INDEX fff ON resume(email (10));
MySQL 里 varchar(64) 采用utf-8编码,能存多少个汉字?或多少个字母?
pt-table-sync使用latin1编码格式无损同步
pt-table-sync --databases=db01 h=127.0.0.1,u=xxxx,p=xxx,A=latin1 h=8.8.8.8,u=xxxx,p=xxx,A=latin1 --lock=0 --charset=latin1 --no-bin-log --no-transaction --execute --print
MySQL8.0解除密码强度限制
SET GLOBAL validate_password.policy = 'LOW';
MySQL 8提供了密码验证策略,可通过系统变量设置:
LOW:基本长度要求。
MEDIUM:必须包含数字、大小写字母、特殊字符。
STRONG:增加更多字符类型和长度要求。
[Server] Plugin mysqlx reported: ‘Setup of socket: ‘/var/lib/mysql/mysqlx.sock’ failed, can’t create lock file /var/lib/mysql/mysqlx.sock.lock’
2025-05-15T12:31:13.701072Z 0 [ERROR] [MY-011300] [Server] Plugin mysqlx reported: ‘Setup of socket: ‘/var/lib/mysql/mysqlx.sock’ failed, can’t create lock file /var/lib/mysql/mysqlx.sock.lock’
因为移动了默认的数据目录导致/var/lib/mysql目录不存在,创建对应的目录即可
mkdir /var/lib/mysql/ && chown mysql:mysql /var/lib/mysql && chmod 755 /var/lib/mysql
[Warning] [MY-011068] [Server] The syntax ‘slave_skip_errors’ is deprecated and will be removed in a future release. Please use replica_skip_errors instead.
2025-05-15T12:24:59.648560Z 0 [Warning] [MY-011068] [Server] The syntax ‘slave_skip_errors’ is deprecated and will be removed in a future release. Please use replica_skip_errors instead.
replica_skip_errors=’1062,1032,1008′
关于select ‘aaa’=’aaa ‘
select 'aaa'='aaa '

SELECT * FROM aaa where a='22222 ';
